Skip to content

Commit 32fed42

Browse files
author
Dale Nguyen
authored
Merge pull request #14 from Zentreax/master
feat: php opening tags (closes #12)
2 parents 5d00f4a + fbd9988 commit 32fed42

14 files changed

+22
-8
lines changed

add_additional_mime_types_to_media_libary.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?php
12
function add_custom_mime_types($mimes){
23
$new_file_types = array (
34
'zip' => 'application/zip',
@@ -9,4 +10,4 @@ function add_custom_mime_types($mimes){
910
return array_merge($mimes,$new_file_types);
1011
}
1112

12-
add_filter('upload_mimes','add_custom_mime_types');
13+
add_filter('upload_mimes','add_custom_mime_types');

add_post_images_to_rss_feed.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?php
12
function add_post_image_to_rss($content) {
23
global $post;
34
if ( has_post_thumbnail( $post->ID ) ){
@@ -7,4 +8,4 @@ function add_post_image_to_rss($content) {
78
}
89

910
add_filter('the_excerpt_rss', 'add_post_images_to_rss');
10-
add_filter('the_content_feed', 'add_post_images_to_rss');
11+
add_filter('the_content_feed', 'add_post_images_to_rss');

define_excerpt_length.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Add this to functions.php
22

3+
<?php
34
function the_excerpt_max_charlength($charlength) {
45
$excerpt = get_the_excerpt();
56
$charlength++;
@@ -17,6 +18,7 @@ function the_excerpt_max_charlength($charlength) {
1718
echo $excerpt;
1819
}
1920
}
21+
?>
2022

2123
// use the following snippet in any file to define the length of the excerpt for this file
2224

disable_self_pingbacks.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?php
12
function disable_self_pingback( &$links ) {
23
$home = get_option( 'home' );
34
foreach ( $links as $l => $link )

exit-if-direct-access-to-file.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
<?php
12
// Exit if direct access attempt to the file for example with a browser
23
defined( 'ABSPATH' ) || exit;

fix-php-undefined-index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?php
12
// Put this code in functions.php
23

34
// Get array value

get-featured-image-from-rest-api.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?php
12
// Put this code in functions.php or a separate plugin
23

34
add_action('rest_api_init', 'register_rest_images' );

get-page-id-from-page-title.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?php
12
// This will return an object of the page
23
$page = get_page_by_title('page-name');
34
$page_id = $page->ID;

get_all_tags_from_a_post.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
// Get an array of tag object from a post id
2-
wp_get_post_tags(get_the_ID());
3-
4-
// Get an array of tags name from a post id
5-
wp_get_post_tags(get_the_ID(), array( 'fields' => 'names' )); // ids
1+
<?php
2+
// Get an array of tag object from a post id
3+
wp_get_post_tags(get_the_ID());
4+
5+
// Get an array of tags name from a post id
6+
wp_get_post_tags(get_the_ID(), array( 'fields' => 'names' )); // ids
67

get_anything_with_page_id.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
<?php
22
// Get the page / post content (easy way)
33
echo get_post_field('post_content', $page_id);
44

0 commit comments

Comments
 (0)