@@ -6,13 +6,13 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Log extends Facade |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Get the fully qualified class name of the component. |
|
| 11 | - * |
|
| 12 | - * @return string |
|
| 13 | - */ |
|
| 14 | - protected static function getFacadeAccessor() |
|
| 15 | - { |
|
| 16 | - return \GeminiLabs\Castor\Helpers\Log::class; |
|
| 17 | - } |
|
| 9 | + /** |
|
| 10 | + * Get the fully qualified class name of the component. |
|
| 11 | + * |
|
| 12 | + * @return string |
|
| 13 | + */ |
|
| 14 | + protected static function getFacadeAccessor() |
|
| 15 | + { |
|
| 16 | + return \GeminiLabs\Castor\Helpers\Log::class; |
|
| 17 | + } |
|
| 18 | 18 | } |
@@ -4,8 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | use GeminiLabs\Castor\Facade; |
| 6 | 6 | |
| 7 | -class Log extends Facade |
|
| 8 | -{ |
|
| 7 | +class Log extends Facade { |
|
| 9 | 8 | /** |
| 10 | 9 | * Get the fully qualified class name of the component. |
| 11 | 10 | * |
@@ -8,8 +8,7 @@ |
||
| 8 | 8 | use GeminiLabs\Castor\Facades\Utility; |
| 9 | 9 | use WP_Customize_Manager; |
| 10 | 10 | |
| 11 | -class Controller |
|
| 12 | -{ |
|
| 11 | +class Controller { |
|
| 13 | 12 | /** |
| 14 | 13 | * @return void |
| 15 | 14 | * @action after_setup_theme |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | public function afterSetupTheme() |
| 18 | 18 | { |
| 19 | - castor_app()->cssDir = trailingslashit( (string) apply_filters( 'castor/assets/styles/dir', 'css' )); |
|
| 20 | - castor_app()->imgDir = trailingslashit( (string) apply_filters( 'castor/assets/images/dir', 'img' )); |
|
| 21 | - castor_app()->jsDir = trailingslashit( (string) apply_filters( 'castor/assets/scripts/dir', 'js' )); |
|
| 19 | + castor_app()->cssDir = trailingslashit( (string) apply_filters( 'castor/assets/styles/dir', 'css' ) ); |
|
| 20 | + castor_app()->imgDir = trailingslashit( (string) apply_filters( 'castor/assets/images/dir', 'img' ) ); |
|
| 21 | + castor_app()->jsDir = trailingslashit( (string) apply_filters( 'castor/assets/scripts/dir', 'js' ) ); |
|
| 22 | 22 | |
| 23 | - add_editor_style( Theme::assetUri( castor_app()->cssDir.'editor.css' )); |
|
| 23 | + add_editor_style( Theme::assetUri( castor_app()->cssDir.'editor.css' ) ); |
|
| 24 | 24 | add_theme_support( 'customize-selective-refresh-widgets' ); |
| 25 | 25 | add_theme_support( 'html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form'] ); |
| 26 | 26 | add_theme_support( 'post-thumbnails' ); |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | add_theme_support( 'soil-nice-search' ); |
| 31 | 31 | add_theme_support( 'soil-relative-urls' ); |
| 32 | 32 | add_theme_support( 'title-tag' ); |
| 33 | - load_theme_textdomain( 'castor', Theme::paths( 'dir.template' ) . '/languages' ); |
|
| 33 | + load_theme_textdomain( 'castor', Theme::paths( 'dir.template' ).'/languages' ); |
|
| 34 | 34 | |
| 35 | 35 | $menus = apply_filters( 'castor/register/nav_menus', [ |
| 36 | 36 | 'main_menu' => __( 'Main Menu', 'castor' ), |
| 37 | - ]); |
|
| 37 | + ] ); |
|
| 38 | 38 | |
| 39 | 39 | foreach( $menus as $location => $description ) { |
| 40 | 40 | register_nav_menu( $location, $description ); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | if( Theme::displaySidebar() ) { |
| 51 | 51 | $classes[] = 'has-sidebar'; |
| 52 | 52 | } |
| 53 | - return array_keys( array_flip( $classes )); |
|
| 53 | + return array_keys( array_flip( $classes ) ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function filterTemplate( $template ) |
| 79 | 79 | { |
| 80 | - if( is_string( $template )) { |
|
| 80 | + if( is_string( $template ) ) { |
|
| 81 | 81 | $template = Template::setLayout( $template ); |
| 82 | 82 | Development::storeTemplatePath( $template ); |
| 83 | 83 | } |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function loadAdminFavicon() |
| 104 | 104 | { |
| 105 | - if( file_exists( Theme::assetPath( 'favicon/favicon-admin.ico' ))) { |
|
| 106 | - printf( '<link rel="shortcut icon" href="%s">', Theme::assetUri( 'favicon/favicon-admin.ico' )); |
|
| 105 | + if( file_exists( Theme::assetPath( 'favicon/favicon-admin.ico' ) ) ) { |
|
| 106 | + printf( '<link rel="shortcut icon" href="%s">', Theme::assetUri( 'favicon/favicon-admin.ico' ) ); |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function login() |
| 115 | 115 | { |
| 116 | - if( file_exists( Theme::assetPath( castor_app()->cssDir.'login.css' ))) { |
|
| 117 | - printf( '<link rel="stylesheet" href="%s">', Theme::assetUri( castor_app()->cssDir.'login.css' )); |
|
| 116 | + if( file_exists( Theme::assetPath( castor_app()->cssDir.'login.css' ) ) ) { |
|
| 117 | + printf( '<link rel="stylesheet" href="%s">', Theme::assetUri( castor_app()->cssDir.'login.css' ) ); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
@@ -124,14 +124,14 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function registerAdminAssets() |
| 126 | 126 | { |
| 127 | - if( file_exists( Theme::assetPath( castor_app()->cssDir.'admin.css' ))) { |
|
| 127 | + if( file_exists( Theme::assetPath( castor_app()->cssDir.'admin.css' ) ) ) { |
|
| 128 | 128 | wp_enqueue_style( 'castor/admin.css', |
| 129 | 129 | Theme::assetUri( castor_app()->cssDir.'admin.css' ), |
| 130 | 130 | apply_filters( 'castor/enqueue/admin/css/deps', [] ), |
| 131 | 131 | null |
| 132 | 132 | ); |
| 133 | 133 | } |
| 134 | - if( file_exists( Theme::assetPath( castor_app()->jsDir.'admin.js' ))) { |
|
| 134 | + if( file_exists( Theme::assetPath( castor_app()->jsDir.'admin.js' ) ) ) { |
|
| 135 | 135 | wp_enqueue_script( 'castor/admin.js', |
| 136 | 136 | Theme::assetUri( castor_app()->jsDir.'admin.js' ), |
| 137 | 137 | apply_filters( 'castor/enqueue/admin/js/deps', [] ), |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | wp_localize_script( 'castor/main.js', apply_filters( 'castor/enqueue/js/localize/variable', 'globals' ), |
| 162 | 162 | apply_filters( 'castor/enqueue/js/localize/variables', [ |
| 163 | 163 | 'ajax' => admin_url( 'admin-ajax.php' ), |
| 164 | - ]) |
|
| 164 | + ] ) |
|
| 165 | 165 | ); |
| 166 | 166 | do_action( 'castor/register/assets' ); |
| 167 | 167 | wp_enqueue_style( 'castor/main.css' ); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | 'render_callback' => function() { |
| 181 | 181 | bloginfo( 'name' ); |
| 182 | 182 | }, |
| 183 | - ]); |
|
| 183 | + ] ); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -203,15 +203,15 @@ discard block |
||
| 203 | 203 | 'after_widget' => '</div>', |
| 204 | 204 | 'before_title' => '<h4>', |
| 205 | 205 | 'after_title' => '</h4>', |
| 206 | - ]); |
|
| 206 | + ] ); |
|
| 207 | 207 | |
| 208 | 208 | $sidebars = apply_filters( 'castor/register/sidebars', [ |
| 209 | 209 | 'sidebar-primary' => __( 'Primary Sidebar', 'castor' ), |
| 210 | 210 | 'sidebar-footer' => __( 'Footer Widgets', 'castor' ), |
| 211 | - ]); |
|
| 211 | + ] ); |
|
| 212 | 212 | |
| 213 | 213 | foreach( $sidebars as $id => $name ) { |
| 214 | - register_sidebar([ |
|
| 214 | + register_sidebar( [ |
|
| 215 | 215 | 'id' => $id, |
| 216 | 216 | 'name' => $name, |
| 217 | 217 | ] + $defaults ); |
@@ -4,6 +4,5 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Exception; |
| 6 | 6 | |
| 7 | -class BindingResolutionException extends Exception |
|
| 8 | -{ |
|
| 7 | +class BindingResolutionException extends Exception { |
|
| 9 | 8 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public static function getInstance( array $aliases = [] ) |
| 42 | 42 | { |
| 43 | - if( is_null( static::$instance )) { |
|
| 43 | + if( is_null( static::$instance ) ) { |
|
| 44 | 44 | return static::$instance = new static( $aliases ); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function load( $alias ) |
| 62 | 62 | { |
| 63 | - if( isset( $this->aliases[$alias] )) { |
|
| 63 | + if( isset( $this->aliases[$alias] ) ) { |
|
| 64 | 64 | return class_alias( $this->aliases[$alias], $alias ); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -2,8 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace GeminiLabs\Castor; |
| 4 | 4 | |
| 5 | -class AliasLoader |
|
| 6 | -{ |
|
| 5 | +class AliasLoader { |
|
| 7 | 6 | /** |
| 8 | 7 | * The singleton instance of the loader. |
| 9 | 8 | * |
@@ -31,7 +30,8 @@ discard block |
||
| 31 | 30 | } |
| 32 | 31 | |
| 33 | 32 | private function __clone() |
| 34 | - {} |
|
| 33 | + { |
|
| 34 | +} |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Get or create the singleton alias loader instance. |
@@ -102,11 +102,11 @@ |
||
| 102 | 102 | */ |
| 103 | 103 | protected static function resolveFacadeInstance( $name ) |
| 104 | 104 | { |
| 105 | - if( is_object( $name )) { |
|
| 105 | + if( is_object( $name ) ) { |
|
| 106 | 106 | return $name; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if( isset( static::$resolvedInstance[$name] )) { |
|
| 109 | + if( isset( static::$resolvedInstance[$name] ) ) { |
|
| 110 | 110 | return static::$resolvedInstance[$name]; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -5,8 +5,7 @@ |
||
| 5 | 5 | use GeminiLabs\Castor\Application; |
| 6 | 6 | use RuntimeException; |
| 7 | 7 | |
| 8 | -abstract class Facade |
|
| 9 | -{ |
|
| 8 | +abstract class Facade { |
|
| 10 | 9 | /** |
| 11 | 10 | * The application instance being facaded. |
| 12 | 11 | * |
@@ -5,8 +5,7 @@ discard block |
||
| 5 | 5 | use GeminiLabs\Castor\Helpers\PostMeta; |
| 6 | 6 | use GeminiLabs\Castor\Helpers\Utility; |
| 7 | 7 | |
| 8 | -class Image |
|
| 9 | -{ |
|
| 8 | +class Image { |
|
| 10 | 9 | public $image; |
| 11 | 10 | |
| 12 | 11 | protected $postmeta; |
@@ -59,7 +58,9 @@ discard block |
||
| 59 | 58 | |
| 60 | 59 | $attachment = get_post( $attachmentId ); |
| 61 | 60 | |
| 62 | - if( is_null( $attachment ) || $attachment->post_type != 'attachment' )return; |
|
| 61 | + if( is_null( $attachment ) || $attachment->post_type != 'attachment' ) { |
|
| 62 | + return; |
|
| 63 | + } |
|
| 63 | 64 | |
| 64 | 65 | return $attachment->ID; |
| 65 | 66 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | public function get( $attachment ) |
| 27 | 27 | { |
| 28 | 28 | $attachment = $this->normalize( $attachment ); |
| 29 | - if( $attachment && $thumbnail = wp_get_attachment_image_src( $attachment, 'thumbnail' )) { |
|
| 29 | + if( $attachment && $thumbnail = wp_get_attachment_image_src( $attachment, 'thumbnail' ) ) { |
|
| 30 | 30 | $medium = $this->normalizeSrc( wp_get_attachment_image_src( $attachment, 'medium' ), $thumbnail ); |
| 31 | 31 | $large = $this->normalizeSrc( wp_get_attachment_image_src( $attachment, 'large' ), $medium ); |
| 32 | 32 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | protected function normalize( $attachmentId ) |
| 55 | 55 | { |
| 56 | - if( !filter_var( $attachmentId, FILTER_VALIDATE_INT )) { |
|
| 56 | + if( !filter_var( $attachmentId, FILTER_VALIDATE_INT ) ) { |
|
| 57 | 57 | $attachmentId = $this->postmeta->get( $attachmentId ); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | protected function normalizeSrc( array $image, $fallback = false ) |
| 73 | 73 | { |
| 74 | - if( is_array( $fallback ) && count( array_diff( $image, $fallback )) < 2 ) { |
|
| 74 | + if( is_array( $fallback ) && count( array_diff( $image, $fallback ) ) < 2 ) { |
|
| 75 | 75 | $image = $fallback; |
| 76 | 76 | } |
| 77 | 77 | $image = array_pad( $image, 3, '' ); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | foreach( $attributes as $key => $value ) { |
| 102 | 102 | // if data attributes, use single quotes in case of json encoded values |
| 103 | 103 | $quotes = false !== stripos( $key, 'data-' ) ? "'" : '"'; |
| 104 | - if( is_array( $value )) { |
|
| 104 | + if( is_array( $value ) ) { |
|
| 105 | 105 | $value = json_encode( $value ); |
| 106 | 106 | $quotes = "'"; |
| 107 | 107 | } |
@@ -144,29 +144,29 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | protected function filterAttributes( array $attributeKeys ) |
| 146 | 146 | { |
| 147 | - $filtered = array_intersect_key( $this->args, array_flip( $attributeKeys )); |
|
| 147 | + $filtered = array_intersect_key( $this->args, array_flip( $attributeKeys ) ); |
|
| 148 | 148 | |
| 149 | 149 | // normalize truthy boolean attributes |
| 150 | 150 | foreach( $filtered as $key => $value ) { |
| 151 | - if( !in_array( $key, self::BOOLEAN_ATTRIBUTES ))continue; |
|
| 151 | + if( !in_array( $key, self::BOOLEAN_ATTRIBUTES ) )continue; |
|
| 152 | 152 | |
| 153 | 153 | if( $value !== false ) { |
| 154 | - $filtered[ $key ] = ''; |
|
| 154 | + $filtered[$key] = ''; |
|
| 155 | 155 | continue; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - unset( $filtered[ $key ] ); |
|
| 158 | + unset( $filtered[$key] ); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | $filteredKeys = array_filter( array_keys( $filtered ), function( $key ) use ( $filtered ) { |
| 162 | 162 | return !( |
| 163 | - empty( $filtered[ $key ] ) |
|
| 164 | - && !is_numeric( $filtered[ $key ] ) |
|
| 163 | + empty( $filtered[$key] ) |
|
| 164 | + && !is_numeric( $filtered[$key] ) |
|
| 165 | 165 | && !in_array( $key, self::BOOLEAN_ATTRIBUTES ) |
| 166 | 166 | ); |
| 167 | 167 | }); |
| 168 | 168 | |
| 169 | - return array_intersect_key( $filtered, array_flip( $filteredKeys )); |
|
| 169 | + return array_intersect_key( $filtered, array_flip( $filteredKeys ) ); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -183,20 +183,20 @@ discard block |
||
| 183 | 183 | foreach( $this->args as $key => $value ) { |
| 184 | 184 | |
| 185 | 185 | $length = strlen( $wildcard ); |
| 186 | - $result = substr( $key, 0, $length) === $wildcard; |
|
| 186 | + $result = substr( $key, 0, $length ) === $wildcard; |
|
| 187 | 187 | |
| 188 | 188 | if( $result ) { |
| 189 | 189 | // only allow data attributes to have an empty value |
| 190 | - if( $wildcard != 'data-' && empty( $value ))continue; |
|
| 190 | + if( $wildcard != 'data-' && empty( $value ) )continue; |
|
| 191 | 191 | |
| 192 | - if( is_array( $value )) { |
|
| 192 | + if( is_array( $value ) ) { |
|
| 193 | 193 | |
| 194 | 194 | if( $wildcard != 'data-' )continue; |
| 195 | 195 | |
| 196 | 196 | $value = json_encode( $value ); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - $wildcards[ $key ] = $value; |
|
| 199 | + $wildcards[$key] = $value; |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | protected function filterInputType() |
| 211 | 211 | { |
| 212 | - if( !isset( $this->args['type'] ) || !in_array( $this->args['type'], self::INPUT_TYPES )) { |
|
| 212 | + if( !isset( $this->args['type'] ) || !in_array( $this->args['type'], self::INPUT_TYPES ) ) { |
|
| 213 | 213 | $this->args['type'] = 'text'; |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | protected function parseAttributes( array $attributes, array $args = [] ) |
| 221 | 221 | { |
| 222 | - if( !empty( $args )) { |
|
| 222 | + if( !empty( $args ) ) { |
|
| 223 | 223 | $this->args = array_change_key_case( $args ); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -2,8 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace GeminiLabs\Castor\Services; |
| 4 | 4 | |
| 5 | -class Normalizer |
|
| 6 | -{ |
|
| 5 | +class Normalizer { |
|
| 7 | 6 | const BOOLEAN_ATTRIBUTES = [ |
| 8 | 7 | 'autofocus', 'capture', 'checked', 'disabled', 'draggable', 'formnovalidate', 'hidden', |
| 9 | 8 | 'multiple', 'novalidate', 'readonly', 'required', 'selected', 'spellcheck', |
@@ -148,7 +147,9 @@ discard block |
||
| 148 | 147 | |
| 149 | 148 | // normalize truthy boolean attributes |
| 150 | 149 | foreach( $filtered as $key => $value ) { |
| 151 | - if( !in_array( $key, self::BOOLEAN_ATTRIBUTES ))continue; |
|
| 150 | + if( !in_array( $key, self::BOOLEAN_ATTRIBUTES )) { |
|
| 151 | + continue; |
|
| 152 | + } |
|
| 152 | 153 | |
| 153 | 154 | if( $value !== false ) { |
| 154 | 155 | $filtered[ $key ] = ''; |
@@ -187,11 +188,15 @@ discard block |
||
| 187 | 188 | |
| 188 | 189 | if( $result ) { |
| 189 | 190 | // only allow data attributes to have an empty value |
| 190 | - if( $wildcard != 'data-' && empty( $value ))continue; |
|
| 191 | + if( $wildcard != 'data-' && empty( $value )) { |
|
| 192 | + continue; |
|
| 193 | + } |
|
| 191 | 194 | |
| 192 | 195 | if( is_array( $value )) { |
| 193 | 196 | |
| 194 | - if( $wildcard != 'data-' )continue; |
|
| 197 | + if( $wildcard != 'data-' ) { |
|
| 198 | + continue; |
|
| 199 | + } |
|
| 195 | 200 | |
| 196 | 201 | $value = json_encode( $value ); |
| 197 | 202 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | public function render() |
| 43 | 43 | { |
| 44 | - if( !isset( $this->video->html ))return; |
|
| 44 | + if( !isset( $this->video->html ) )return; |
|
| 45 | 45 | return sprintf( |
| 46 | 46 | '<div class="video embed">%s%s</div>', |
| 47 | 47 | $this->renderScreenshot(), |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | public function renderPlayButton() |
| 53 | 53 | { |
| 54 | 54 | return sprintf( |
| 55 | - '<div class="video-play">' . |
|
| 56 | - '<div class="video-play-pulse pulse1"></div>' . |
|
| 57 | - '<div class="video-play-pulse pulse2"></div>' . |
|
| 58 | - '<div class="video-play-pulse pulse3"></div>' . |
|
| 59 | - '<a href="%s" class="video-play-btn">%s</a>' . |
|
| 55 | + '<div class="video-play">'. |
|
| 56 | + '<div class="video-play-pulse pulse1"></div>'. |
|
| 57 | + '<div class="video-play-pulse pulse2"></div>'. |
|
| 58 | + '<div class="video-play-pulse pulse3"></div>'. |
|
| 59 | + '<a href="%s" class="video-play-btn">%s</a>'. |
|
| 60 | 60 | '</div>', |
| 61 | 61 | $this->args['url'], |
| 62 | 62 | $this->theme->svg( 'play.svg' ) |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | public function renderScreenshot() |
| 67 | 67 | { |
| 68 | 68 | if( $this->args['image'] |
| 69 | - && in_array( strtolower( $this->video->provider_name ), $this->supported )) { |
|
| 69 | + && in_array( strtolower( $this->video->provider_name ), $this->supported ) ) { |
|
| 70 | 70 | return sprintf( '%s<div class="video-poster" style="background-image: url(%s)">%s</div>', |
| 71 | 71 | $this->renderSpinner(), |
| 72 | 72 | $this->args['image'], |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | public function renderSpinner() |
| 79 | 79 | { |
| 80 | 80 | return sprintf( |
| 81 | - '<div class="video-spinner">' . |
|
| 82 | - '<div class="spinner"><div class="spinner-dots">%s</div></div>' . |
|
| 81 | + '<div class="video-spinner">'. |
|
| 82 | + '<div class="spinner"><div class="spinner-dots">%s</div></div>'. |
|
| 83 | 83 | '</div>', |
| 84 | - implode( '', array_fill( 0, 8, '<div class="spinner-dot"></div>' )) |
|
| 84 | + implode( '', array_fill( 0, 8, '<div class="spinner-dot"></div>' ) ) |
|
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | protected function normalize( $args ) |
| 104 | 104 | { |
| 105 | - if( is_string( $args )) { |
|
| 105 | + if( is_string( $args ) ) { |
|
| 106 | 106 | $args = ['url' => $args]; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $this->args = shortcode_atts([ |
|
| 109 | + $this->args = shortcode_atts( [ |
|
| 110 | 110 | 'image' => '', // string || int |
| 111 | 111 | 'player' => '', // string || array |
| 112 | 112 | 'url' => '', // string |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | foreach( $this->args as $key => $value ) { |
| 116 | 116 | $method = $this->utility->buildMethodName( $key, 'set' ); |
| 117 | - if( !method_exists( $this, $method ))continue; |
|
| 118 | - call_user_func([ $this, $method ], $value ); |
|
| 117 | + if( !method_exists( $this, $method ) )continue; |
|
| 118 | + call_user_func( [$this, $method], $value ); |
|
| 119 | 119 | } |
| 120 | 120 | return $this->args; |
| 121 | 121 | } |
@@ -8,8 +8,7 @@ discard block |
||
| 8 | 8 | use GeminiLabs\Castor\Image; |
| 9 | 9 | use GeminiLabs\Castor\Oembed; |
| 10 | 10 | |
| 11 | -class Video |
|
| 12 | -{ |
|
| 11 | +class Video { |
|
| 13 | 12 | public $video; |
| 14 | 13 | |
| 15 | 14 | protected $args; |
@@ -41,7 +40,9 @@ discard block |
||
| 41 | 40 | |
| 42 | 41 | public function render() |
| 43 | 42 | { |
| 44 | - if( !isset( $this->video->html ))return; |
|
| 43 | + if( !isset( $this->video->html )) { |
|
| 44 | + return; |
|
| 45 | + } |
|
| 45 | 46 | return sprintf( |
| 46 | 47 | '<div class="video embed">%s%s</div>', |
| 47 | 48 | $this->renderScreenshot(), |
@@ -114,7 +115,9 @@ discard block |
||
| 114 | 115 | |
| 115 | 116 | foreach( $this->args as $key => $value ) { |
| 116 | 117 | $method = $this->utility->buildMethodName( $key, 'set' ); |
| 117 | - if( !method_exists( $this, $method ))continue; |
|
| 118 | + if( !method_exists( $this, $method )) { |
|
| 119 | + continue; |
|
| 120 | + } |
|
| 118 | 121 | call_user_func([ $this, $method ], $value ); |
| 119 | 122 | } |
| 120 | 123 | return $this->args; |
@@ -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 | |