Skip to content

Commit 112fddb

Browse files
author
Dale Nguyen
authored
Merge pull request #22 from omnisite/master
chore: apply WordPress Coding Standards
2 parents 28280d4 + 5a76152 commit 112fddb

17 files changed

+101
-100
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
2-
function add_custom_mime_types($mimes){
2+
function add_custom_mime_types( $mimes ) {
33
$new_file_types = array (
4-
'zip' => 'application/zip',
5-
'pdf' => 'application/pdf',
4+
'zip' => 'application/zip',
5+
'pdf' => 'application/pdf',
66
'epub' => 'application/epub+zip',
77
//add more here
88
);
99

10-
return array_merge($mimes,$new_file_types);
10+
return array_merge( $mimes,$new_file_types );
1111
}
1212

13-
add_filter('upload_mimes','add_custom_mime_types');
13+
add_filter( 'upload_mimes','add_custom_mime_types' );
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
2-
function add_post_image_to_rss($content) {
2+
function add_post_image_to_rss( $content ) {
33
global $post;
4-
if ( has_post_thumbnail( $post->ID ) ){
4+
if ( has_post_thumbnail( $post->ID ) ) {
55
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'large', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
66
}
77
return $content;
88
}
99

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

src/define_excerpt_length.php

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

33
<?php
4-
function the_excerpt_max_charlength($charlength) {
4+
function the_excerpt_max_charlength( $charlength ) {
55
$excerpt = get_the_excerpt();
66
$charlength++;
77
if ( mb_strlen( $excerpt ) > $charlength ) {
8-
$subex = mb_substr( $excerpt, 0, $charlength - 5 );
8+
$subex = mb_substr( $excerpt, 0, $charlength - 5 );
99
$exwords = explode( ' ', $subex );
10-
$excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
10+
$excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
1111
if ( $excut < 0 ) {
1212
echo mb_substr( $subex, 0, $excut );
1313
} else {

src/disable_self_pingbacks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ function disable_self_pingback( &$links ) {
33
$home = get_option( 'home' );
44
foreach ( $links as $l => $link )
55
if ( 0 === strpos( $link, $home ) )
6-
unset($links[$l]);
6+
unset( $links[$l] );
77
}
88
add_action( 'pre_ping', 'disable_self_pingback' );

src/embed_responsive_16_to_9_videos.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
function responsive_videos( $html ){
22
$html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
3-
return'<div class="embed-responsive embed-responsive-16by9">'.$html.'</div>';
3+
return '<div class="embed-responsive embed-responsive-16by9">' . $html . '</div>';
44
}
55

6-
add_filter( 'embed_oembed_html','evolution_wrap_oembed',10,1);
6+
add_filter( 'embed_oembed_html','evolution_wrap_oembed', 10, 1 );
77

88
//needed CSS Classes
99

src/fix_php_undefined_index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// Put this code in functions.php
33

44
// Get array value
5-
function idx($array, $key){
6-
if(isset($array[$key])){
5+
function idx( $array, $key ) {
6+
if ( isset( $array[$key] ) ) {
77
return $array[$key];
8-
}else{
8+
} else {
99
return NULL;
1010
}
1111
}

src/get_all_tags_from_a_post.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
// Get an array of tag object from a post id
3-
wp_get_post_tags(get_the_ID());
3+
wp_get_post_tags( get_the_ID() );
44

55
// Get an array of tags name from a post id
6-
wp_get_post_tags(get_the_ID(), array( 'fields' => 'names' )); // ids
7-
6+
wp_get_post_tags( get_the_ID(), array( 'fields' => 'names' ) ); // ids

src/get_anything_with_page_id.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?php
22
// Get the page / post content (easy way)
3-
echo get_post_field('post_content', $page_id);
3+
echo get_post_field( 'post_content', $page_id );
44

55
// $more_link_text Optional. Content for when there is more text. Default is null
66
// $stripteaser Optional. Strip teaser content before the more text. Default is false.
77

8-
$post = get_post($page_id);
9-
setup_postdata( $post, $more_link_text, $stripteaser);
8+
$post = get_post( $page_id );
9+
setup_postdata( $post, $more_link_text, $stripteaser );
1010
the_content();
1111

1212
// get other info by using ID
13-
get_the_permalink($page_id);
14-
get_the_title($page_id);
15-
get_the_post_thumbnail_url($page_id);
16-
get_the_excerpt($page_id);
17-
get_the_date( 'l F j, Y', $page_id);
13+
get_the_permalink( $page_id );
14+
get_the_title( $page_id );
15+
get_the_post_thumbnail_url( $page_id );
16+
get_the_excerpt( $page_id );
17+
get_the_date( 'l F j, Y', $page_id );
1818

1919
// Check if the page is front page or not
20-
get_option("page_on_front") == $page_id;
20+
get_option( 'page_on_front' ) == $page_id;

src/get_featured_image_from_rest_api.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22
// Put this code in functions.php or a separate plugin
33

4-
add_action('rest_api_init', 'register_rest_images' );
4+
add_action( 'rest_api_init', 'register_rest_images' );
55

6-
function register_rest_images(){
7-
register_rest_field( array('post'),
6+
function register_rest_images() {
7+
register_rest_field( array( 'post' ),
88
'fimg_url',
99
array(
1010
'get_callback' => 'get_rest_featured_image',
@@ -15,7 +15,7 @@ function register_rest_images(){
1515
}
1616

1717
function get_rest_featured_image( $object, $field_name, $request ) {
18-
if( $object['featured_media'] ){
18+
if ( $object['featured_media'] ) {
1919
$img = wp_get_attachment_image_src( $object['featured_media'], 'app-thumb' );
2020
return $img[0];
2121
}

src/get_number_of_posts_in_term.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99

1010
//Show the number of posts of any term by any identifier (e.g. for the term category and the term with id 1)
1111

12-
$term = get_term_by('id', 1, 'category');
12+
$term = get_term_by( 'id', 1, 'category' );
1313
$term->count();

0 commit comments

Comments
 (0)