@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $this->normalizeArgs( $args ); |
| 36 | 36 | |
| 37 | - $this->gallery = new WP_Query([ |
|
| 37 | + $this->gallery = new WP_Query( [ |
|
| 38 | 38 | 'orderby' => 'post__in', |
| 39 | 39 | 'paged' => $this->getPaged(), |
| 40 | 40 | 'post__in' => $this->args['media'], |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | 'post_type' => 'attachment', |
| 43 | 43 | 'post_status' => 'inherit', |
| 44 | 44 | 'posts_per_page' => $this->args['images_per_page'], |
| 45 | - ]); |
|
| 45 | + ] ); |
|
| 46 | 46 | |
| 47 | 47 | return $this; |
| 48 | 48 | } |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function render() |
| 54 | 54 | { |
| 55 | - if( empty( $this->args['media'] ))return; |
|
| 55 | + if( empty( $this->args['media'] ) )return; |
|
| 56 | 56 | $images = array_reduce( $this->gallery->posts, function( $images, $attachment ) { |
| 57 | - return $images . $this->renderImage( $attachment ); |
|
| 57 | + return $images.$this->renderImage( $attachment ); |
|
| 58 | 58 | }); |
| 59 | 59 | return sprintf( '<div class="gallery-images" itemscope itemtype="http://schema.org/ImageGallery">%s</div>%s', |
| 60 | 60 | $images, |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | if( !$image )return; |
| 73 | 73 | return sprintf( |
| 74 | - '<figure class="gallery-image" data-w="%s" data-h="%s" data-ps=\'%s\' itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">' . |
|
| 75 | - '%s%s' . |
|
| 74 | + '<figure class="gallery-image" data-w="%s" data-h="%s" data-ps=\'%s\' itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">'. |
|
| 75 | + '%s%s'. |
|
| 76 | 76 | '</figure>', |
| 77 | 77 | $image->thumbnail['width'], |
| 78 | 78 | $image->thumbnail['height'], |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | public function renderPagination() |
| 89 | 89 | { |
| 90 | 90 | if( !$this->args['pagination'] )return; |
| 91 | - return paginate_links([ |
|
| 92 | - 'before_page_number' => '<span class="screen-reader-text">' . __( 'Page', 'castor' ) . ' </span>', |
|
| 91 | + return paginate_links( [ |
|
| 92 | + 'before_page_number' => '<span class="screen-reader-text">'.__( 'Page', 'castor' ).' </span>', |
|
| 93 | 93 | 'current' => $this->gallery->query['paged'], |
| 94 | 94 | 'mid_size' => 1, |
| 95 | 95 | 'next_text' => __( 'Next', 'castor' ), |
| 96 | 96 | 'prev_text' => __( 'Previous', 'castor' ), |
| 97 | 97 | 'total' => $this->gallery->max_num_pages, |
| 98 | - ]); |
|
| 98 | + ] ); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | $bool = $this->getValue( $key, $value ); |
| 110 | 110 | |
| 111 | - if( is_null( filter_var( $bool, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ))) { |
|
| 111 | + if( is_null( filter_var( $bool, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ) ) ) { |
|
| 112 | 112 | $bool = $this->postmeta->get( $bool ); |
| 113 | 113 | } |
| 114 | 114 | return wp_validate_boolean( $bool ); |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | { |
| 124 | 124 | $gallery = $this->getValue( 'gallery', $value ); |
| 125 | 125 | |
| 126 | - if( !is_numeric( $gallery ) && is_string( $gallery )) { |
|
| 127 | - $gallery = intval( $this->postmeta->get( $gallery )); |
|
| 126 | + if( !is_numeric( $gallery ) && is_string( $gallery ) ) { |
|
| 127 | + $gallery = intval( $this->postmeta->get( $gallery ) ); |
|
| 128 | 128 | } |
| 129 | - return !is_null( get_post( $gallery )) |
|
| 129 | + return !is_null( get_post( $gallery ) ) |
|
| 130 | 130 | ? intval( $gallery ) |
| 131 | 131 | : 0; |
| 132 | 132 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | { |
| 141 | 141 | $perPage = $this->getValue( 'images_per_page', $value ); |
| 142 | 142 | |
| 143 | - if( !is_numeric( $perPage ) && is_string( $perPage )) { |
|
| 143 | + if( !is_numeric( $perPage ) && is_string( $perPage ) ) { |
|
| 144 | 144 | $perPage = $this->postmeta->get( $perPage ); |
| 145 | 145 | } |
| 146 | 146 | return !!intval( $perPage ) |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | { |
| 168 | 168 | $media = $this->getValue( 'media', $value ); |
| 169 | 169 | |
| 170 | - if( is_string( $media )) { |
|
| 170 | + if( is_string( $media ) ) { |
|
| 171 | 171 | $media = $this->postmeta->get( $media, [ |
| 172 | 172 | 'ID' => $this->getGalleryArg(), |
| 173 | 173 | 'single' => false, |
| 174 | - ]); |
|
| 174 | + ] ); |
|
| 175 | 175 | } |
| 176 | 176 | return is_array( $media ) |
| 177 | 177 | ? wp_parse_id_list( $media ) |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | protected function getPaged() |
| 185 | 185 | { |
| 186 | - return intval( get_query_var(( is_front_page() ? 'page' : 'paged' ))) ?: 1; |
|
| 186 | + return intval( get_query_var( ( is_front_page() ? 'page' : 'paged' ) ) ) ?: 1; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | protected function getValue( $key, $value = null ) |
| 231 | 231 | { |
| 232 | - if( is_null( $value ) && isset( $this->args[$key] )) { |
|
| 232 | + if( is_null( $value ) && isset( $this->args[$key] ) ) { |
|
| 233 | 233 | $value = $this->args[$key]; |
| 234 | 234 | } |
| 235 | 235 | return $value; |
@@ -241,20 +241,20 @@ discard block |
||
| 241 | 241 | protected function normalizeArgs( array $args = [] ) |
| 242 | 242 | { |
| 243 | 243 | $defaults = [ |
| 244 | - 'gallery', // (string) meta_key | (int) post_id |
|
| 245 | - 'lazyload', // (string) meta_key | (bool) |
|
| 246 | - 'media', // (string) meta_key | (array) post_ids |
|
| 247 | - 'pagination', // (string) meta_key | (bool) |
|
| 244 | + 'gallery', // (string) meta_key | (int) post_id |
|
| 245 | + 'lazyload', // (string) meta_key | (bool) |
|
| 246 | + 'media', // (string) meta_key | (array) post_ids |
|
| 247 | + 'pagination', // (string) meta_key | (bool) |
|
| 248 | 248 | 'images_per_page', // (string) meta_key | (int) number |
| 249 | - 'permalinks', // (string) meta_key | (bool) |
|
| 249 | + 'permalinks', // (string) meta_key | (bool) |
|
| 250 | 250 | ]; |
| 251 | 251 | |
| 252 | 252 | $this->args = shortcode_atts( array_combine( $defaults, $defaults ), $args ); |
| 253 | 253 | |
| 254 | 254 | array_walk( $this->args, function( &$value, $key ) { |
| 255 | - $method = $this->utility->buildMethodName( $key . '_arg' ); |
|
| 256 | - if( method_exists( $this, $method )) { |
|
| 257 | - $value = call_user_func([ $this, $method ], $value ); |
|
| 255 | + $method = $this->utility->buildMethodName( $key.'_arg' ); |
|
| 256 | + if( method_exists( $this, $method ) ) { |
|
| 257 | + $value = call_user_func( [$this, $method], $value ); |
|
| 258 | 258 | } |
| 259 | 259 | }); |
| 260 | 260 | |
@@ -267,10 +267,10 @@ discard block |
||
| 267 | 267 | */ |
| 268 | 268 | protected function renderImageCaption( $image ) |
| 269 | 269 | { |
| 270 | - if( !empty( $image->copyright )) { |
|
| 270 | + if( !empty( $image->copyright ) ) { |
|
| 271 | 271 | $image->caption .= sprintf( ' <span itemprop="copyrightHolder">%s</span>', $image->copyright ); |
| 272 | 272 | } |
| 273 | - if( empty( $image->caption ))return; |
|
| 273 | + if( empty( $image->caption ) )return; |
|
| 274 | 274 | return sprintf( '<figcaption itemprop="caption description">%s</figcaption>', $image->caption ); |
| 275 | 275 | } |
| 276 | 276 | |
@@ -9,8 +9,7 @@ discard block |
||
| 9 | 9 | use WP_Post; |
| 10 | 10 | use WP_Query; |
| 11 | 11 | |
| 12 | -class Gallery |
|
| 13 | -{ |
|
| 12 | +class Gallery { |
|
| 14 | 13 | public $gallery; |
| 15 | 14 | |
| 16 | 15 | protected $args; |
@@ -52,7 +51,9 @@ discard block |
||
| 52 | 51 | */ |
| 53 | 52 | public function render() |
| 54 | 53 | { |
| 55 | - if( empty( $this->args['media'] ))return; |
|
| 54 | + if( empty( $this->args['media'] )) { |
|
| 55 | + return; |
|
| 56 | + } |
|
| 56 | 57 | $images = array_reduce( $this->gallery->posts, function( $images, $attachment ) { |
| 57 | 58 | return $images . $this->renderImage( $attachment ); |
| 58 | 59 | }); |
@@ -69,7 +70,9 @@ discard block |
||
| 69 | 70 | { |
| 70 | 71 | $image = $this->image->get( $attachment->ID )->image; |
| 71 | 72 | |
| 72 | - if( !$image )return; |
|
| 73 | + if( !$image ) { |
|
| 74 | + return; |
|
| 75 | + } |
|
| 73 | 76 | return sprintf( |
| 74 | 77 | '<figure class="gallery-image" data-w="%s" data-h="%s" data-ps=\'%s\' itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">' . |
| 75 | 78 | '%s%s' . |
@@ -87,7 +90,9 @@ discard block |
||
| 87 | 90 | */ |
| 88 | 91 | public function renderPagination() |
| 89 | 92 | { |
| 90 | - if( !$this->args['pagination'] )return; |
|
| 93 | + if( !$this->args['pagination'] ) { |
|
| 94 | + return; |
|
| 95 | + } |
|
| 91 | 96 | return paginate_links([ |
| 92 | 97 | 'before_page_number' => '<span class="screen-reader-text">' . __( 'Page', 'castor' ) . ' </span>', |
| 93 | 98 | 'current' => $this->gallery->query['paged'], |
@@ -270,7 +275,9 @@ discard block |
||
| 270 | 275 | if( !empty( $image->copyright )) { |
| 271 | 276 | $image->caption .= sprintf( ' <span itemprop="copyrightHolder">%s</span>', $image->copyright ); |
| 272 | 277 | } |
| 273 | - if( empty( $image->caption ))return; |
|
| 278 | + if( empty( $image->caption )) { |
|
| 279 | + return; |
|
| 280 | + } |
|
| 274 | 281 | return sprintf( '<figcaption itemprop="caption description">%s</figcaption>', $image->caption ); |
| 275 | 282 | } |
| 276 | 283 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function buildAttributesFor( $tag, array $atts = [] ) |
| 23 | 23 | { |
| 24 | 24 | return $this->buildAttributes( |
| 25 | - wp_parse_args( $atts, apply_filters( "castor/render/$tag/attributes", [] )) |
|
| 25 | + wp_parse_args( $atts, apply_filters( "castor/render/$tag/attributes", [] ) ) |
|
| 26 | 26 | ); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function buildClassName( $name, $path = '' ) |
| 36 | 36 | { |
| 37 | - $className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ))); |
|
| 37 | + $className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ) ) ); |
|
| 38 | 38 | $className = implode( '', $className ); |
| 39 | 39 | |
| 40 | 40 | return !empty( $path ) |
| 41 | - ? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className )) |
|
| 41 | + ? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className ) ) |
|
| 42 | 42 | : $className; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function buildMethodName( $name, $prefix = 'get' ) |
| 52 | 52 | { |
| 53 | - return lcfirst( $this->buildClassName( $prefix . '-' . $name )); |
|
| 53 | + return lcfirst( $this->buildClassName( $prefix.'-'.$name ) ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | { |
| 76 | 76 | return $unique && $this->endsWith( $suffix, $string ) |
| 77 | 77 | ? $string |
| 78 | - : $string . $suffix; |
|
| 78 | + : $string.$suffix; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $attributes = $this->buildAttributesFor( $tag, $attributes ); |
| 104 | 104 | |
| 105 | 105 | printf( '<%s>%s</%s>', |
| 106 | - rtrim( sprintf( '%s %s', $tag, $attributes )), |
|
| 106 | + rtrim( sprintf( '%s %s', $tag, $attributes ) ), |
|
| 107 | 107 | $value, |
| 108 | 108 | $tag |
| 109 | 109 | ); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | return $unique && $this->startsWith( $prefix, $string ) |
| 122 | 122 | ? $string |
| 123 | - : $prefix . $string; |
|
| 123 | + : $prefix.$string; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function startsWith( $needle, $haystack ) |
| 133 | 133 | { |
| 134 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
| 134 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -141,10 +141,10 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | public function toArray( $value ) |
| 143 | 143 | { |
| 144 | - if( is_string( $value )) { |
|
| 144 | + if( is_string( $value ) ) { |
|
| 145 | 145 | $value = trim( $value ); |
| 146 | 146 | } |
| 147 | - return array_filter((array) $value ); |
|
| 147 | + return array_filter( (array) $value ); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | { |
| 159 | 159 | $strPos = $caseSensitive ? "strpos" : "stripos"; |
| 160 | 160 | if( $strPos( $string, $needle ) === 0 ) { |
| 161 | - $string = substr( $string, strlen( $needle )); |
|
| 161 | + $string = substr( $string, strlen( $needle ) ); |
|
| 162 | 162 | } |
| 163 | 163 | return $string; |
| 164 | 164 | } |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | public function trimRight( $string, $needle, $caseSensitive = true ) |
| 174 | 174 | { |
| 175 | 175 | $strPos = $caseSensitive ? "strpos" : "stripos"; |
| 176 | - if( $strPos( $string, $needle, strlen( $string ) - strlen( $needle )) !== false ) { |
|
| 177 | - $string = substr( $string, 0, -strlen( $needle )); |
|
| 176 | + if( $strPos( $string, $needle, strlen( $string ) - strlen( $needle ) ) !== false ) { |
|
| 177 | + $string = substr( $string, 0, -strlen( $needle ) ); |
|
| 178 | 178 | } |
| 179 | 179 | return $string; |
| 180 | 180 | } |
@@ -2,8 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace GeminiLabs\Castor\Helpers; |
| 4 | 4 | |
| 5 | -class Utility |
|
| 6 | -{ |
|
| 5 | +class Utility { |
|
| 7 | 6 | /** |
| 8 | 7 | * @return string |
| 9 | 8 | */ |
@@ -13,8 +13,7 @@ |
||
| 13 | 13 | * |
| 14 | 14 | * @property object all |
| 15 | 15 | */ |
| 16 | -class ArchiveMeta extends SiteMeta |
|
| 17 | -{ |
|
| 16 | +class ArchiveMeta extends SiteMeta { |
|
| 18 | 17 | protected $options; |
| 19 | 18 | |
| 20 | 19 | public function __construct() |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function assetPath( $asset ) |
| 24 | 24 | { |
| 25 | - return $this->paths( 'dir.stylesheet' ) . 'assets/' . $asset; |
|
| 25 | + return $this->paths( 'dir.stylesheet' ).'assets/'.$asset; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function assetUri( $asset ) |
| 34 | 34 | { |
| 35 | - return $this->paths( 'uri.stylesheet' ) . 'assets/' . $asset; |
|
| 35 | + return $this->paths( 'uri.stylesheet' ).'assets/'.$asset; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function copyright() |
| 42 | 42 | { |
| 43 | - return __( 'Copyright', 'castor' ) . ' © ' . date( 'Y' ) . ', ' . get_bloginfo( 'name' ); |
|
| 43 | + return __( 'Copyright', 'castor' ).' © '.date( 'Y' ).', '.get_bloginfo( 'name' ); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function imagePath( $asset ) |
| 68 | 68 | { |
| 69 | - return $this->paths( 'dir.stylesheet' ) . 'assets/img/' . $asset; |
|
| 69 | + return $this->paths( 'dir.stylesheet' ).'assets/img/'.$asset; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function imageUri( $asset ) |
| 78 | 78 | { |
| 79 | - return $this->paths( 'uri.stylesheet' ) . 'assets/img/' . $asset; |
|
| 79 | + return $this->paths( 'uri.stylesheet' ).'assets/img/'.$asset; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | public function pageTitle() |
| 83 | 83 | { |
| 84 | 84 | foreach( ['is_404', 'is_archive', 'is_home', 'is_page', 'is_search'] as $bool ) { |
| 85 | 85 | if( !$bool() )continue; |
| 86 | - $method = sprintf( 'get%sTitle', ucfirst( str_replace( 'is_', '', $bool ))); |
|
| 86 | + $method = sprintf( 'get%sTitle', ucfirst( str_replace( 'is_', '', $bool ) ) ); |
|
| 87 | 87 | return $this->$method(); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | 'uri.template' => get_template_directory_uri(), |
| 106 | 106 | ]; |
| 107 | 107 | |
| 108 | - if( is_null( $path )) { |
|
| 108 | + if( is_null( $path ) ) { |
|
| 109 | 109 | return $paths; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function svg( $path = null ) |
| 123 | 123 | { |
| 124 | - if( file_exists( $this->imagePath( $path ))) { |
|
| 125 | - return file_get_contents( $this->imagePath( $path )); |
|
| 124 | + if( file_exists( $this->imagePath( $path ) ) ) { |
|
| 125 | + return file_get_contents( $this->imagePath( $path ) ); |
|
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | protected function getArchiveTitle() |
| 135 | 135 | { |
| 136 | - return $this->archiveMeta->get( 'title', get_the_archive_title(), get_query_var( 'post_type' )); |
|
| 136 | + return $this->archiveMeta->get( 'title', get_the_archive_title(), get_query_var( 'post_type' ) ); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | protected function getHomeTitle() |
| 140 | 140 | { |
| 141 | - return ( $home = get_option( 'page_for_posts', true )) |
|
| 141 | + return ( $home = get_option( 'page_for_posts', true ) ) |
|
| 142 | 142 | ? get_the_title( $home ) |
| 143 | 143 | : __( 'Latest Posts', 'castor' ); |
| 144 | 144 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | { |
| 148 | 148 | return $this->postMeta->get( 'title', [ |
| 149 | 149 | 'fallback' => get_the_title(), |
| 150 | - ]); |
|
| 150 | + ] ); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | protected function getSearchTitle() |
@@ -4,8 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use GeminiLabs\Castor\Helpers\PostMeta; |
| 6 | 6 | |
| 7 | -class Theme |
|
| 8 | -{ |
|
| 7 | +class Theme { |
|
| 9 | 8 | public $archiveMeta; |
| 10 | 9 | public $postMeta; |
| 11 | 10 | |
@@ -82,7 +81,9 @@ discard block |
||
| 82 | 81 | public function pageTitle() |
| 83 | 82 | { |
| 84 | 83 | foreach( ['is_404', 'is_archive', 'is_home', 'is_page', 'is_search'] as $bool ) { |
| 85 | - if( !$bool() )continue; |
|
| 84 | + if( !$bool() ) { |
|
| 85 | + continue; |
|
| 86 | + } |
|
| 86 | 87 | $method = sprintf( 'get%sTitle', ucfirst( str_replace( 'is_', '', $bool ))); |
| 87 | 88 | return $this->$method(); |
| 88 | 89 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | $args = array_pad( $args, 2, null ); |
| 30 | 30 | $group = $this->$group; |
| 31 | - if( is_object( $group )) { |
|
| 31 | + if( is_object( $group ) ) { |
|
| 32 | 32 | return $group; |
| 33 | 33 | } |
| 34 | 34 | return $this->get( $group, $args[0], $args[1] ); |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | if( $group == 'all' ) { |
| 44 | 44 | return (object) $this->options; |
| 45 | 45 | } |
| 46 | - if( empty( $group )) { |
|
| 46 | + if( empty( $group ) ) { |
|
| 47 | 47 | $group = $this->getDefaultGroup(); |
| 48 | 48 | } |
| 49 | - if( is_array( $group )) { |
|
| 49 | + if( is_array( $group ) ) { |
|
| 50 | 50 | $group = reset( $group ); |
| 51 | 51 | } |
| 52 | 52 | return isset( $this->options[$group] ) |
@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | if( func_num_args() < 1 ) { |
| 66 | 66 | return $this->all; |
| 67 | 67 | } |
| 68 | - if( is_string( $group )) { |
|
| 68 | + if( is_string( $group ) ) { |
|
| 69 | 69 | $group = $this->$group; |
| 70 | 70 | } |
| 71 | - if( !is_array( $group )) { |
|
| 71 | + if( !is_array( $group ) ) { |
|
| 72 | 72 | return $fallback; |
| 73 | 73 | } |
| 74 | - if( is_null( $key )) { |
|
| 74 | + if( is_null( $key ) ) { |
|
| 75 | 75 | return $group; |
| 76 | 76 | } |
| 77 | 77 | return $this->getValue( $group, $key, $fallback ); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | protected function getValue( array $group, $key = '', $fallback ) |
| 94 | 94 | { |
| 95 | - if( empty( $key ) || !array_key_exists( $key, $group )) { |
|
| 95 | + if( empty( $key ) || !array_key_exists( $key, $group ) ) { |
|
| 96 | 96 | return $fallback; |
| 97 | 97 | } |
| 98 | 98 | return empty( $group[$key] ) && !is_null( $fallback ) |
@@ -11,8 +11,7 @@ |
||
| 11 | 11 | * |
| 12 | 12 | * @property object all |
| 13 | 13 | */ |
| 14 | -class SiteMeta |
|
| 15 | -{ |
|
| 14 | +class SiteMeta { |
|
| 16 | 15 | protected $options; |
| 17 | 16 | |
| 18 | 17 | public function __construct() |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public function blockquote( $metaKey = false, array $attributes = [] ) |
| 26 | 26 | { |
| 27 | - if( $value = $this->postmeta->get( $metaKey )) { |
|
| 27 | + if( $value = $this->postmeta->get( $metaKey ) ) { |
|
| 28 | 28 | $this->utility->printTag( 'blockquote', wp_strip_all_tags( $value ), $attributes ); |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | if( $passthrough ) { |
| 35 | 35 | $url = $postId; |
| 36 | 36 | } |
| 37 | - if( !isset( $url )) { |
|
| 37 | + if( !isset( $url ) ) { |
|
| 38 | 38 | $url = get_permalink( $postId ); |
| 39 | 39 | if( !$title ) { |
| 40 | 40 | $title = get_the_title( $postId ); |
@@ -56,18 +56,18 @@ discard block |
||
| 56 | 56 | if( $passthrough ) { |
| 57 | 57 | $content = $metaKey; |
| 58 | 58 | } |
| 59 | - if( !isset( $content )) { |
|
| 59 | + if( !isset( $content ) ) { |
|
| 60 | 60 | $content = $metaKey |
| 61 | 61 | ? $this->postmeta->get( $metaKey ) |
| 62 | 62 | : get_the_content(); |
| 63 | 63 | } |
| 64 | - echo str_replace( ']]>', ']]>', apply_filters( 'the_content', $content )); |
|
| 64 | + echo str_replace( ']]>', ']]>', apply_filters( 'the_content', $content ) ); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public function copyright( array $args = [] ) |
| 68 | 68 | { |
| 69 | - $args = shortcode_atts([ |
|
| 70 | - 'copyright' => sprintf( '<span>%s </span>©', __( 'Copyright', 'castor' )), |
|
| 69 | + $args = shortcode_atts( [ |
|
| 70 | + 'copyright' => sprintf( '<span>%s </span>©', __( 'Copyright', 'castor' ) ), |
|
| 71 | 71 | 'date' => date( 'Y' ), |
| 72 | 72 | 'name' => get_bloginfo( 'name' ), |
| 73 | 73 | 'separator' => '—', |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | 'image' => get_post_thumbnail_id(), |
| 87 | 87 | 'player' => '', |
| 88 | 88 | 'video' => 'featured_video', |
| 89 | - ]); |
|
| 89 | + ] ); |
|
| 90 | 90 | $featuredHtml = $this->media->video( wp_parse_args( $args, [ |
| 91 | 91 | 'url' => $args['video'], |
| 92 | - ])); |
|
| 93 | - if( empty( $featuredHtml ) && $featuredImage = $this->media->getImage( $args['image'] )) { |
|
| 92 | + ] ) ); |
|
| 93 | + if( empty( $featuredHtml ) && $featuredImage = $this->media->getImage( $args['image'] ) ) { |
|
| 94 | 94 | $featuredCaption = $featuredImage->caption |
| 95 | 95 | ? sprintf( '<figcaption>%s</figcaption>', $featuredImage->caption ) |
| 96 | 96 | : ''; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $featuredCaption |
| 101 | 101 | ); |
| 102 | 102 | } |
| 103 | - if( !empty( $featuredHtml )) { |
|
| 103 | + if( !empty( $featuredHtml ) ) { |
|
| 104 | 104 | printf( '<figure class="%s">%s</figure>', $args['class'], $featuredHtml ); |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | public function madeWithLove( $name ) |
| 146 | 146 | { |
| 147 | 147 | printf( __( 'Made with %s by %s', 'castor' ), |
| 148 | - file_get_contents( sprintf( '%simg/heart.svg', \GeminiLabs\Castor\Application::getInstance()->assets )), |
|
| 148 | + file_get_contents( sprintf( '%simg/heart.svg', \GeminiLabs\Castor\Application::getInstance()->assets ) ), |
|
| 149 | 149 | $name |
| 150 | 150 | ); |
| 151 | 151 | } |
@@ -7,8 +7,7 @@ discard block |
||
| 7 | 7 | use GeminiLabs\Castor\Helpers\Theme; |
| 8 | 8 | use GeminiLabs\Castor\Helpers\Utility; |
| 9 | 9 | |
| 10 | -class Render |
|
| 11 | -{ |
|
| 10 | +class Render { |
|
| 12 | 11 | public $media; |
| 13 | 12 | public $postmeta; |
| 14 | 13 | public $theme; |
@@ -40,7 +39,9 @@ discard block |
||
| 40 | 39 | $title = get_the_title( $postId ); |
| 41 | 40 | } |
| 42 | 41 | } |
| 43 | - if( !$title || !$url )return; |
|
| 42 | + if( !$title || !$url ) { |
|
| 43 | + return; |
|
| 44 | + } |
|
| 44 | 45 | printf( '<a href="%s" class="button"><span>%s</span></a>', $url, $title ); |
| 45 | 46 | } |
| 46 | 47 | |
@@ -118,27 +119,33 @@ discard block |
||
| 118 | 119 | echo $this->media->gallery( $args ); |
| 119 | 120 | } |
| 120 | 121 | |
| 121 | - public function h1( $string, array $attributes = [] ) { |
|
| 122 | + public function h1( $string, array $attributes = [] ) |
|
| 123 | + { |
|
| 122 | 124 | $this->utility->printTag( 'h1', wp_strip_all_tags( $string ), $attributes ); |
| 123 | 125 | } |
| 124 | 126 | |
| 125 | - public function h2( $string, array $attributes = [] ) { |
|
| 127 | + public function h2( $string, array $attributes = [] ) |
|
| 128 | + { |
|
| 126 | 129 | $this->utility->printTag( 'h2', wp_strip_all_tags( $string ), $attributes ); |
| 127 | 130 | } |
| 128 | 131 | |
| 129 | - public function h3( $string, array $attributes = [] ) { |
|
| 132 | + public function h3( $string, array $attributes = [] ) |
|
| 133 | + { |
|
| 130 | 134 | $this->utility->printTag( 'h3', wp_strip_all_tags( $string ), $attributes ); |
| 131 | 135 | } |
| 132 | 136 | |
| 133 | - public function h4( $string, array $attributes = [] ) { |
|
| 137 | + public function h4( $string, array $attributes = [] ) |
|
| 138 | + { |
|
| 134 | 139 | $this->utility->printTag( 'h4', wp_strip_all_tags( $string ), $attributes ); |
| 135 | 140 | } |
| 136 | 141 | |
| 137 | - public function h5( $string, array $attributes = [] ) { |
|
| 142 | + public function h5( $string, array $attributes = [] ) |
|
| 143 | + { |
|
| 138 | 144 | $this->utility->printTag( 'h5', wp_strip_all_tags( $string ), $attributes ); |
| 139 | 145 | } |
| 140 | 146 | |
| 141 | - public function h6( $string, array $attributes = [] ) { |
|
| 147 | + public function h6( $string, array $attributes = [] ) |
|
| 148 | + { |
|
| 142 | 149 | $this->utility->printTag( 'h6', wp_strip_all_tags( $string ), $attributes ); |
| 143 | 150 | } |
| 144 | 151 | |
@@ -150,7 +157,8 @@ discard block |
||
| 150 | 157 | ); |
| 151 | 158 | } |
| 152 | 159 | |
| 153 | - public function p( $string, array $attributes = [] ) { |
|
| 160 | + public function p( $string, array $attributes = [] ) |
|
| 161 | + { |
|
| 154 | 162 | $this->utility->printTag( 'p', wp_strip_all_tags( $string ), $attributes ); |
| 155 | 163 | } |
| 156 | 164 | |
@@ -161,7 +169,9 @@ discard block |
||
| 161 | 169 | ? $this->postmeta->get( $metaKey ) |
| 162 | 170 | : $this->theme->pageTitle(); |
| 163 | 171 | |
| 164 | - if( !$value )return; |
|
| 172 | + if( !$value ) { |
|
| 173 | + return; |
|
| 174 | + } |
|
| 165 | 175 | |
| 166 | 176 | $this->utility->printTag( $tag, wp_strip_all_tags( $value ), $attributes ); |
| 167 | 177 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | protected function interpolate( $message, array $context = [] ) |
| 152 | 152 | { |
| 153 | - if( is_array( $message )) { |
|
| 153 | + if( is_array( $message ) ) { |
|
| 154 | 154 | return htmlspecialchars( print_r( $message, true ), ENT_QUOTES, 'UTF-8' ); |
| 155 | 155 | } |
| 156 | 156 | $replace = []; |
@@ -158,10 +158,10 @@ discard block |
||
| 158 | 158 | if( is_object( $val ) && get_class( $val ) === 'DateTime' ) { |
| 159 | 159 | $val = $val->format( 'Y-m-d H:i:s' ); |
| 160 | 160 | } |
| 161 | - else if( is_object( $val ) || is_array( $val )) { |
|
| 161 | + else if( is_object( $val ) || is_array( $val ) ) { |
|
| 162 | 162 | $val = json_encode( $val ); |
| 163 | 163 | } |
| 164 | - else if( is_resource( $val )) { |
|
| 164 | + else if( is_resource( $val ) ) { |
|
| 165 | 165 | $val = (string) $val; |
| 166 | 166 | } |
| 167 | 167 | $replace['{'.$key.'}'] = $val; |
@@ -179,12 +179,12 @@ discard block |
||
| 179 | 179 | { |
| 180 | 180 | if( !defined( 'CASTOR_DEBUG' ) |
| 181 | 181 | || CASTOR_DEBUG !== true |
| 182 | - || !in_array( $level, (new ReflectionClass( __NAMESPACE__.'\Log' ))->getConstants(), true ) |
|
| 182 | + || !in_array( $level, ( new ReflectionClass( __NAMESPACE__.'\Log' ) )->getConstants(), true ) |
|
| 183 | 183 | )return; |
| 184 | - $date = get_date_from_gmt( gmdate('Y-m-d H:i:s') ); |
|
| 184 | + $date = get_date_from_gmt( gmdate( 'Y-m-d H:i:s' ) ); |
|
| 185 | 185 | $level = strtoupper( $level ); |
| 186 | 186 | $message = $this->interpolate( $message, $context ); |
| 187 | - $entry = "[$date] $level: $message" . PHP_EOL; |
|
| 188 | - file_put_contents( $this->file, $entry, FILE_APPEND|LOCK_EX ); |
|
| 187 | + $entry = "[$date] $level: $message".PHP_EOL; |
|
| 188 | + file_put_contents( $this->file, $entry, FILE_APPEND | LOCK_EX ); |
|
| 189 | 189 | } |
| 190 | 190 | } |
@@ -4,8 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use ReflectionClass; |
| 6 | 6 | |
| 7 | -class Log |
|
| 8 | -{ |
|
| 7 | +class Log { |
|
| 9 | 8 | const EMERGENCY = 'emergency'; |
| 10 | 9 | const ALERT = 'alert'; |
| 11 | 10 | const CRITICAL = 'critical'; |
@@ -180,7 +179,9 @@ discard block |
||
| 180 | 179 | if( !defined( 'CASTOR_DEBUG' ) |
| 181 | 180 | || CASTOR_DEBUG !== true |
| 182 | 181 | || !in_array( $level, (new ReflectionClass( __NAMESPACE__.'\Log' ))->getConstants(), true ) |
| 183 | - )return; |
|
| 182 | + ) { |
|
| 183 | + return; |
|
| 184 | + } |
|
| 184 | 185 | $date = get_date_from_gmt( gmdate('Y-m-d H:i:s') ); |
| 185 | 186 | $level = strtoupper( $level ); |
| 186 | 187 | $message = $this->interpolate( $message, $context ); |
@@ -16,13 +16,13 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | public function get( $metaKey, array $args = [] ) |
| 18 | 18 | { |
| 19 | - if( empty( $metaKey ))return; |
|
| 19 | + if( empty( $metaKey ) )return; |
|
| 20 | 20 | |
| 21 | 21 | $args = $this->normalize( $args ); |
| 22 | 22 | $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
| 23 | 23 | $metaValue = get_post_meta( $args['id'], $metaKey, $args['single'] ); |
| 24 | 24 | |
| 25 | - if( is_string( $metaValue )) { |
|
| 25 | + if( is_string( $metaValue ) ) { |
|
| 26 | 26 | $metaValue = trim( $metaValue ); |
| 27 | 27 | } |
| 28 | 28 | return empty( $metaValue ) |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | protected function buildMetaKey( $metaKey, $prefix ) |
| 39 | 39 | { |
| 40 | - return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix )) |
|
| 40 | + return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix ) ) |
|
| 41 | 41 | ? sprintf( '_%s%s', rtrim( $prefix, '_' ), $metaKey ) |
| 42 | - : $prefix . $metaKey; |
|
| 42 | + : $prefix.$metaKey; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -53,6 +53,6 @@ discard block |
||
| 53 | 53 | 'single' => true, |
| 54 | 54 | 'prefix' => apply_filters( 'pollux/prefix', 'pollux_' ), |
| 55 | 55 | ]; |
| 56 | - return shortcode_atts( $defaults, array_change_key_case( $args )); |
|
| 56 | + return shortcode_atts( $defaults, array_change_key_case( $args ) ); |
|
| 57 | 57 | } |
| 58 | 58 | } |
@@ -8,15 +8,16 @@ |
||
| 8 | 8 | * 'fallback' => [], |
| 9 | 9 | * ]); |
| 10 | 10 | */ |
| 11 | -class PostMeta |
|
| 12 | -{ |
|
| 11 | +class PostMeta { |
|
| 13 | 12 | /** |
| 14 | 13 | * @param string $metaKey |
| 15 | 14 | * @return mixed |
| 16 | 15 | */ |
| 17 | 16 | public function get( $metaKey, array $args = [] ) |
| 18 | 17 | { |
| 19 | - if( empty( $metaKey ))return; |
|
| 18 | + if( empty( $metaKey )) { |
|
| 19 | + return; |
|
| 20 | + } |
|
| 20 | 21 | |
| 21 | 22 | $args = $this->normalize( $args ); |
| 22 | 23 | $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $mediaType = $this->validateMethod( $name ); |
| 39 | 39 | $args = $this->validateArgs( $args, $mediaType ); |
| 40 | 40 | |
| 41 | - if( str_replace( $mediaType, '', strtolower( $name ))) { |
|
| 41 | + if( str_replace( $mediaType, '', strtolower( $name ) ) ) { |
|
| 42 | 42 | return $this->$mediaType->get( $args[0] )->$mediaType; |
| 43 | 43 | } |
| 44 | 44 | return !empty( $args[1] ) |
@@ -68,10 +68,10 @@ discard block |
||
| 68 | 68 | if( !count( $args ) && $name == 'image' ) { |
| 69 | 69 | $args[] = get_post_thumbnail_id(); |
| 70 | 70 | } |
| 71 | - if( count( $args )) { |
|
| 71 | + if( count( $args ) ) { |
|
| 72 | 72 | return $args; |
| 73 | 73 | } |
| 74 | - throw new BadMethodCallException( sprintf( 'Missing arguments for: %s', $name )); |
|
| 74 | + throw new BadMethodCallException( sprintf( 'Missing arguments for: %s', $name ) ); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | protected function validateMethod( $name ) |
| 83 | 83 | { |
| 84 | - foreach( [$name, strtolower( substr( $name, 3 ))] as $method ) { |
|
| 85 | - if( property_exists( $this, $method ) && is_object( $this->$method )) { |
|
| 84 | + foreach( [$name, strtolower( substr( $name, 3 ) )] as $method ) { |
|
| 85 | + if( property_exists( $this, $method ) && is_object( $this->$method ) ) { |
|
| 86 | 86 | return $method; |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | - throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name )); |
|
| 89 | + throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name ) ); |
|
| 90 | 90 | } |
| 91 | 91 | } |
@@ -15,8 +15,7 @@ |
||
| 15 | 15 | * @method object|void getImage( int|string $attachment ) |
| 16 | 16 | * @method object|void getVideo( string|array $args ) |
| 17 | 17 | */ |
| 18 | -class Media |
|
| 19 | -{ |
|
| 18 | +class Media { |
|
| 20 | 19 | protected $gallery; |
| 21 | 20 | protected $image; |
| 22 | 21 | protected $video; |