@@ -45,25 +45,25 @@ discard block |
||
| 45 | 45 | * @return array |
| 46 | 46 | */ |
| 47 | 47 | public static function get_vars() { |
| 48 | - if ( is_null( self::$vars ) ) { |
|
| 48 | + if (is_null(self::$vars)) { |
|
| 49 | 49 | // Check for a theme config. |
| 50 | - $config_file = CLASSY_THEME_FRAMEWORK_PATH . '/custom/config.php'; |
|
| 50 | + $config_file = CLASSY_THEME_FRAMEWORK_PATH.'/custom/config.php'; |
|
| 51 | 51 | |
| 52 | - if ( ! file_exists( $config_file ) ) { |
|
| 53 | - wp_die( sprintf( |
|
| 52 | + if (!file_exists($config_file)) { |
|
| 53 | + wp_die(sprintf( |
|
| 54 | 54 | 'There is no config file in %s custom/config.php', |
| 55 | - esc_html( CLASSY_THEME ) |
|
| 56 | - ) ); |
|
| 55 | + esc_html(CLASSY_THEME) |
|
| 56 | + )); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - require_once( $config_file ); |
|
| 59 | + require_once($config_file); |
|
| 60 | 60 | $vars = self::get_allowed_variables(); |
| 61 | 61 | |
| 62 | - foreach ( $vars as $var ) { |
|
| 63 | - if ( isset( $$var ) ) { |
|
| 64 | - self::$vars[ $var ] = $$var; |
|
| 62 | + foreach ($vars as $var) { |
|
| 63 | + if (isset($$var)) { |
|
| 64 | + self::$vars[$var] = $$var; |
|
| 65 | 65 | |
| 66 | - unset( $$var ); // We don't require it anymore. |
|
| 66 | + unset($$var); // We don't require it anymore. |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -78,23 +78,23 @@ discard block |
||
| 78 | 78 | $vars = self::get_vars(); |
| 79 | 79 | |
| 80 | 80 | // Init Post Types. |
| 81 | - if ( isset( $vars['post_types'] ) ) { |
|
| 82 | - self::init_post_types( $vars['post_types'] ); |
|
| 81 | + if (isset($vars['post_types'])) { |
|
| 82 | + self::init_post_types($vars['post_types']); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // Init Taxonomies. |
| 86 | - if ( isset( $vars['taxonomies'] ) ) { |
|
| 87 | - self::init_taxonomies( $vars['taxonomies'] ); |
|
| 86 | + if (isset($vars['taxonomies'])) { |
|
| 87 | + self::init_taxonomies($vars['taxonomies']); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // Init Post Formats. |
| 91 | - if ( isset( $vars['post_formats'] ) ) { |
|
| 92 | - self::init_post_formats( $vars['post_formats'] ); |
|
| 91 | + if (isset($vars['post_formats'])) { |
|
| 92 | + self::init_post_formats($vars['post_formats']); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Init Sidebars. |
| 96 | - if ( isset( $vars['sidebars'] ) ) { |
|
| 97 | - self::init_sidebars( $vars['sidebars'] ); |
|
| 96 | + if (isset($vars['sidebars'])) { |
|
| 97 | + self::init_sidebars($vars['sidebars']); |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @param array $post_types Custom post types to be registered. |
| 105 | 105 | */ |
| 106 | - private static function init_post_types( $post_types ) { |
|
| 107 | - if ( is_array( $post_types ) ) { |
|
| 108 | - foreach ( $post_types as $type => $options ) { |
|
| 106 | + private static function init_post_types($post_types) { |
|
| 107 | + if (is_array($post_types)) { |
|
| 108 | + foreach ($post_types as $type => $options) { |
|
| 109 | 109 | self::add_post_type( |
| 110 | 110 | $type, |
| 111 | 111 | $options['config'], |
@@ -124,25 +124,25 @@ discard block |
||
| 124 | 124 | * @param string $singular Optional. Default singular name. |
| 125 | 125 | * @param string $multiple Optional. Default multiple name. |
| 126 | 126 | */ |
| 127 | - private static function add_post_type( $name, $config, $singular = 'Entry', $multiple = 'Entries' ) { |
|
| 127 | + private static function add_post_type($name, $config, $singular = 'Entry', $multiple = 'Entries') { |
|
| 128 | 128 | $domain = Classy::textdomain(); |
| 129 | 129 | |
| 130 | - if ( ! isset( $config['labels'] ) ) { |
|
| 130 | + if (!isset($config['labels'])) { |
|
| 131 | 131 | $config['labels'] = array( |
| 132 | - 'name' => __( $multiple, $domain ), |
|
| 133 | - 'singular_name' => __( $singular, $domain ), |
|
| 134 | - 'not_found' => __( 'No ' . $multiple . ' Found', $domain ), |
|
| 135 | - 'not_found_in_trash' => __( 'No ' . $multiple . ' found in Trash', $domain ), |
|
| 136 | - 'edit_item' => __( 'Edit ', $singular, $domain ), |
|
| 137 | - 'search_items' => __( 'Search ' . $multiple, $domain ), |
|
| 138 | - 'view_item' => __( 'View ', $singular, $domain ), |
|
| 139 | - 'new_item' => __( 'New ' . $singular, $domain ), |
|
| 140 | - 'add_new' => __( 'Add New', $domain ), |
|
| 141 | - 'add_new_item' => __( 'Add New ' . $singular, $domain ), |
|
| 132 | + 'name' => __($multiple, $domain), |
|
| 133 | + 'singular_name' => __($singular, $domain), |
|
| 134 | + 'not_found' => __('No '.$multiple.' Found', $domain), |
|
| 135 | + 'not_found_in_trash' => __('No '.$multiple.' found in Trash', $domain), |
|
| 136 | + 'edit_item' => __('Edit ', $singular, $domain), |
|
| 137 | + 'search_items' => __('Search '.$multiple, $domain), |
|
| 138 | + 'view_item' => __('View ', $singular, $domain), |
|
| 139 | + 'new_item' => __('New '.$singular, $domain), |
|
| 140 | + 'add_new' => __('Add New', $domain), |
|
| 141 | + 'add_new_item' => __('Add New '.$singular, $domain), |
|
| 142 | 142 | ); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - register_post_type( $name, $config ); |
|
| 145 | + register_post_type($name, $config); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @param array $taxonomies Taxonomies to be registered. |
| 152 | 152 | */ |
| 153 | - private static function init_taxonomies( $taxonomies ) { |
|
| 154 | - if ( is_array( $taxonomies ) ) { |
|
| 155 | - foreach ( $taxonomies as $type => $options ) { |
|
| 153 | + private static function init_taxonomies($taxonomies) { |
|
| 154 | + if (is_array($taxonomies)) { |
|
| 155 | + foreach ($taxonomies as $type => $options) { |
|
| 156 | 156 | self::add_taxonomy( |
| 157 | 157 | $type, |
| 158 | 158 | $options['for'], |
@@ -173,26 +173,26 @@ discard block |
||
| 173 | 173 | * @param string $singular Optional. Default singular name. |
| 174 | 174 | * @param string $multiple Optional. Default multiple name. |
| 175 | 175 | */ |
| 176 | - private static function add_taxonomy( $name, $object_type, $config, $singular = 'Entry', $multiple = 'Entries' ) { |
|
| 176 | + private static function add_taxonomy($name, $object_type, $config, $singular = 'Entry', $multiple = 'Entries') { |
|
| 177 | 177 | $domain = Classy::textdomain(); |
| 178 | 178 | |
| 179 | - if ( ! isset( $config['labels'] ) ) { |
|
| 179 | + if (!isset($config['labels'])) { |
|
| 180 | 180 | $config['labels'] = array( |
| 181 | - 'name' => __( $multiple, $domain ), |
|
| 182 | - 'singular_name' => __( $singular, $domain ), |
|
| 183 | - 'search_items' => __( 'Search ' . $multiple, $domain ), |
|
| 184 | - 'all_items' => __( 'All ' . $multiple, $domain ), |
|
| 185 | - 'parent_item' => __( 'Parent ' . $singular, $domain ), |
|
| 186 | - 'parent_item_colon' => __( 'Parent ' . $singular . ':', $domain ), |
|
| 187 | - 'edit_item' => __( 'Edit ' . $singular, $domain ), |
|
| 188 | - 'update_item' => __( 'Update ' . $singular, $domain ), |
|
| 189 | - 'add_new_item' => __( 'Add New ' . $singular, $domain ), |
|
| 190 | - 'new_item_name' => __( 'New ' . $singular . ' Name', $domain ), |
|
| 191 | - 'menu_name' => __( $singular, $domain ), |
|
| 181 | + 'name' => __($multiple, $domain), |
|
| 182 | + 'singular_name' => __($singular, $domain), |
|
| 183 | + 'search_items' => __('Search '.$multiple, $domain), |
|
| 184 | + 'all_items' => __('All '.$multiple, $domain), |
|
| 185 | + 'parent_item' => __('Parent '.$singular, $domain), |
|
| 186 | + 'parent_item_colon' => __('Parent '.$singular.':', $domain), |
|
| 187 | + 'edit_item' => __('Edit '.$singular, $domain), |
|
| 188 | + 'update_item' => __('Update '.$singular, $domain), |
|
| 189 | + 'add_new_item' => __('Add New '.$singular, $domain), |
|
| 190 | + 'new_item_name' => __('New '.$singular.' Name', $domain), |
|
| 191 | + 'menu_name' => __($singular, $domain), |
|
| 192 | 192 | ); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - register_taxonomy( $name, $object_type, $config ); |
|
| 195 | + register_taxonomy($name, $object_type, $config); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -200,9 +200,9 @@ discard block |
||
| 200 | 200 | * |
| 201 | 201 | * @param array $post_formats Array with available post formats. |
| 202 | 202 | */ |
| 203 | - private static function init_post_formats( $post_formats ) { |
|
| 204 | - if ( is_array( $post_formats ) ) { |
|
| 205 | - add_theme_support( 'post-formats', $post_formats ); |
|
| 203 | + private static function init_post_formats($post_formats) { |
|
| 204 | + if (is_array($post_formats)) { |
|
| 205 | + add_theme_support('post-formats', $post_formats); |
|
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | |
@@ -211,16 +211,16 @@ discard block |
||
| 211 | 211 | * |
| 212 | 212 | * @param array $sidebars Sidebars to be registered. |
| 213 | 213 | */ |
| 214 | - private static function init_sidebars( $sidebars ) { |
|
| 214 | + private static function init_sidebars($sidebars) { |
|
| 215 | 215 | $domain = Classy::textdomain(); |
| 216 | 216 | |
| 217 | - if ( is_array( $sidebars ) ) { |
|
| 218 | - foreach ( $sidebars as $id => $title ) { |
|
| 217 | + if (is_array($sidebars)) { |
|
| 218 | + foreach ($sidebars as $id => $title) { |
|
| 219 | 219 | register_sidebar( |
| 220 | 220 | array( |
| 221 | 221 | 'id' => $id, |
| 222 | - 'name' => __( $title, $domain ), |
|
| 223 | - 'description' => __( $title, $domain ), |
|
| 222 | + 'name' => __($title, $domain), |
|
| 223 | + 'description' => __($title, $domain), |
|
| 224 | 224 | 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-inner">', |
| 225 | 225 | 'after_widget' => '</div></div>', |
| 226 | 226 | 'before_title' => '<h3>', |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public static function get_instance() { |
| 34 | 34 | |
| 35 | - if ( null === self::$single_instance ) { |
|
| 35 | + if (null === self::$single_instance) { |
|
| 36 | 36 | |
| 37 | 37 | self::$single_instance = new self(); |
| 38 | 38 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | $this->load_custom_includes(); |
| 62 | 62 | |
| 63 | - add_filter( 'theme_page_templates', array( $this, 'filter_templates' ) ); |
|
| 63 | + add_filter('theme_page_templates', array($this, 'filter_templates')); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -74,20 +74,20 @@ discard block |
||
| 74 | 74 | * Load template functions. |
| 75 | 75 | */ |
| 76 | 76 | private function load_template_function() { |
| 77 | - require_once( CLASSY_THEME_FRAMEWORK_PATH . 'core/functions/template-functions.php' ); |
|
| 77 | + require_once(CLASSY_THEME_FRAMEWORK_PATH.'core/functions/template-functions.php'); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Loads custom files specified in custom/config.php. |
| 82 | 82 | */ |
| 83 | 83 | private function load_custom_includes() { |
| 84 | - $include = self::get_config_var( 'include' ); |
|
| 84 | + $include = self::get_config_var('include'); |
|
| 85 | 85 | |
| 86 | - if ( is_array( $include ) ) { |
|
| 87 | - foreach ( $include as $file ) { |
|
| 88 | - $files = (array) glob( CLASSY_THEME_FRAMEWORK_PATH . 'custom/' . $file ); |
|
| 89 | - foreach ( $files as $filename ) { |
|
| 90 | - if ( is_readable( $filename ) ) { |
|
| 86 | + if (is_array($include)) { |
|
| 87 | + foreach ($include as $file) { |
|
| 88 | + $files = (array) glob(CLASSY_THEME_FRAMEWORK_PATH.'custom/'.$file); |
|
| 89 | + foreach ($files as $filename) { |
|
| 90 | + if (is_readable($filename)) { |
|
| 91 | 91 | require_once $filename; |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -105,13 +105,13 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | $theme = wp_get_theme(); |
| 107 | 107 | |
| 108 | - define( 'CLASSY_THEME', $theme->template ); |
|
| 109 | - define( 'CLASSY_THEME_NAME', $theme->get( 'Name' ) ); |
|
| 110 | - define( 'CLASSY_THEME_PATH', get_template_directory() . '/' ); |
|
| 111 | - define( 'CLASSY_THEME_DIR', get_template_directory_uri() . '/' ); |
|
| 112 | - define( 'CLASSY_THEME_VERSION', $theme->get( 'Version' ) ); |
|
| 113 | - define( 'CLASSY_THEME_FRAMEWORK_PATH', CLASSY_THEME_PATH . 'app/' ); |
|
| 114 | - define( 'CLASSY_THEME_FRAMEWORK_DIR', CLASSY_THEME_DIR . 'app/' ); |
|
| 108 | + define('CLASSY_THEME', $theme->template); |
|
| 109 | + define('CLASSY_THEME_NAME', $theme->get('Name')); |
|
| 110 | + define('CLASSY_THEME_PATH', get_template_directory().'/'); |
|
| 111 | + define('CLASSY_THEME_DIR', get_template_directory_uri().'/'); |
|
| 112 | + define('CLASSY_THEME_VERSION', $theme->get('Version')); |
|
| 113 | + define('CLASSY_THEME_FRAMEWORK_PATH', CLASSY_THEME_PATH.'app/'); |
|
| 114 | + define('CLASSY_THEME_FRAMEWORK_DIR', CLASSY_THEME_DIR.'app/'); |
|
| 115 | 115 | |
| 116 | 116 | } |
| 117 | 117 | |
@@ -129,11 +129,11 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return array |
| 131 | 131 | */ |
| 132 | - public function filter_templates( $page_templates = array() ) { |
|
| 132 | + public function filter_templates($page_templates = array()) { |
|
| 133 | 133 | |
| 134 | 134 | $custom_templates = View::get_page_templates_list(); |
| 135 | 135 | |
| 136 | - return array_merge( $page_templates, $custom_templates ); |
|
| 136 | + return array_merge($page_templates, $custom_templates); |
|
| 137 | 137 | |
| 138 | 138 | } |
| 139 | 139 | |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @return mixed|bool Return false if variable not found. |
| 146 | 146 | */ |
| 147 | - public static function get_config_var( $name ) { |
|
| 147 | + public static function get_config_var($name) { |
|
| 148 | 148 | |
| 149 | 149 | $vars = Config::get_vars(); |
| 150 | 150 | |
| 151 | - return ( isset( $vars[ $name ] ) ) ? $vars[ $name ] : false; |
|
| 151 | + return (isset($vars[$name])) ? $vars[$name] : false; |
|
| 152 | 152 | |
| 153 | 153 | } |
| 154 | 154 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public static function textdomain() { |
| 161 | 161 | |
| 162 | - $textdomain = Classy::get_config_var( 'textdomain' ); |
|
| 162 | + $textdomain = Classy::get_config_var('textdomain'); |
|
| 163 | 163 | |
| 164 | 164 | return $textdomain ? $textdomain : CLASSY_THEME; |
| 165 | 165 | |
@@ -174,17 +174,17 @@ discard block |
||
| 174 | 174 | * @param array|null $data Additional params. |
| 175 | 175 | * @return void |
| 176 | 176 | */ |
| 177 | - public static function render( $view = null, $data = null ) { |
|
| 177 | + public static function render($view = null, $data = null) { |
|
| 178 | 178 | |
| 179 | - $views = CLASSY_THEME_PATH . View::$folder; |
|
| 180 | - $cache = WP_CONTENT_DIR . '/viewcache'; |
|
| 179 | + $views = CLASSY_THEME_PATH.View::$folder; |
|
| 180 | + $cache = WP_CONTENT_DIR.'/viewcache'; |
|
| 181 | 181 | $common_scope = Scope::get_common_scope(); |
| 182 | 182 | |
| 183 | - if ( null !== $view && is_string( $view ) ) { |
|
| 183 | + if (null !== $view && is_string($view)) { |
|
| 184 | 184 | |
| 185 | - if ( $data && is_array( $data ) ) { |
|
| 185 | + if ($data && is_array($data)) { |
|
| 186 | 186 | |
| 187 | - $scope = array_merge( $common_scope, $data ); |
|
| 187 | + $scope = array_merge($common_scope, $data); |
|
| 188 | 188 | |
| 189 | 189 | } else { |
| 190 | 190 | |
@@ -199,11 +199,11 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - $renderer = new BladeRenderer( $views, array( 'cache_path' => $cache ) ); |
|
| 202 | + $renderer = new BladeRenderer($views, array('cache_path' => $cache)); |
|
| 203 | 203 | |
| 204 | - $html = $renderer->render( $view, $scope ); |
|
| 204 | + $html = $renderer->render($view, $scope); |
|
| 205 | 205 | |
| 206 | - echo self::maybe_minify( $html ); |
|
| 206 | + echo self::maybe_minify($html); |
|
| 207 | 207 | |
| 208 | 208 | } |
| 209 | 209 | |
@@ -213,13 +213,13 @@ discard block |
||
| 213 | 213 | * @param string $html HTML string. |
| 214 | 214 | * @return string |
| 215 | 215 | */ |
| 216 | - private static function maybe_minify( $html ) { |
|
| 216 | + private static function maybe_minify($html) { |
|
| 217 | 217 | |
| 218 | - $minify_html = self::get_config_var( 'minify_html' ); |
|
| 218 | + $minify_html = self::get_config_var('minify_html'); |
|
| 219 | 219 | |
| 220 | - if ( true === $minify_html ) { |
|
| 220 | + if (true === $minify_html) { |
|
| 221 | 221 | |
| 222 | - $html = self::minify_html( $html ); |
|
| 222 | + $html = self::minify_html($html); |
|
| 223 | 223 | |
| 224 | 224 | } |
| 225 | 225 | |
@@ -233,13 +233,13 @@ discard block |
||
| 233 | 233 | * @param string $html HTML string. |
| 234 | 234 | * @return string |
| 235 | 235 | */ |
| 236 | - private static function minify_html( $html ) { |
|
| 236 | + private static function minify_html($html) { |
|
| 237 | 237 | |
| 238 | 238 | $search = array( |
| 239 | 239 | "/\n/s", |
| 240 | - '/\>[^\S ]+/s', // Strip whitespaces after tags, except space. |
|
| 241 | - '/[^\S ]+\</s', // Strip whitespaces before tags, except space. |
|
| 242 | - '/(\s)+/s', // Shorten multiple whitespace sequences. |
|
| 240 | + '/\>[^\S ]+/s', // Strip whitespaces after tags, except space. |
|
| 241 | + '/[^\S ]+\</s', // Strip whitespaces before tags, except space. |
|
| 242 | + '/(\s)+/s', // Shorten multiple whitespace sequences. |
|
| 243 | 243 | '/<!--(.|\s)*?-->/', |
| 244 | 244 | ); |
| 245 | 245 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | '', |
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | - return preg_replace( $search, $replace, $html ); |
|
| 254 | + return preg_replace($search, $replace, $html); |
|
| 255 | 255 | |
| 256 | 256 | } |
| 257 | 257 | |
@@ -276,27 +276,27 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return array |
| 278 | 278 | */ |
| 279 | - public static function get_posts( $args = false, $return = '\Classy\Models\Post' ) { |
|
| 279 | + public static function get_posts($args = false, $return = '\Classy\Models\Post') { |
|
| 280 | 280 | |
| 281 | 281 | $_return = array(); |
| 282 | 282 | |
| 283 | - $query = Query_Helper::find_query( $args ); |
|
| 283 | + $query = Query_Helper::find_query($args); |
|
| 284 | 284 | |
| 285 | - if ( isset( $query->posts ) ) { |
|
| 285 | + if (isset($query->posts)) { |
|
| 286 | 286 | |
| 287 | - foreach ( $query->posts as $post ) { |
|
| 287 | + foreach ($query->posts as $post) { |
|
| 288 | 288 | |
| 289 | - if ( 'id' === $return ) { |
|
| 289 | + if ('id' === $return) { |
|
| 290 | 290 | |
| 291 | 291 | $_return[] = $post->id; |
| 292 | 292 | |
| 293 | - } elseif ( 'object' === $return ) { |
|
| 293 | + } elseif ('object' === $return) { |
|
| 294 | 294 | |
| 295 | 295 | $_return[] = $post; |
| 296 | 296 | |
| 297 | - } elseif ( class_exists( $return ) ) { |
|
| 297 | + } elseif (class_exists($return)) { |
|
| 298 | 298 | |
| 299 | - $_return[] = new $return( $post ); |
|
| 299 | + $_return[] = new $return($post); |
|
| 300 | 300 | |
| 301 | 301 | } |
| 302 | 302 | } |
@@ -314,11 +314,11 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @return mixed |
| 316 | 316 | */ |
| 317 | - public static function get_post( $args = false, $return_type = '\Classy\Models\Post' ) { |
|
| 317 | + public static function get_post($args = false, $return_type = '\Classy\Models\Post') { |
|
| 318 | 318 | |
| 319 | - $posts = self::get_posts( $args, $return_type ); |
|
| 319 | + $posts = self::get_posts($args, $return_type); |
|
| 320 | 320 | |
| 321 | - if ( $post = reset( $posts ) ) { |
|
| 321 | + if ($post = reset($posts)) { |
|
| 322 | 322 | return $post; |
| 323 | 323 | } |
| 324 | 324 | |
@@ -331,62 +331,62 @@ discard block |
||
| 331 | 331 | * |
| 332 | 332 | * @return array mixed |
| 333 | 333 | */ |
| 334 | - public static function get_pagination( $prefs = array() ) { |
|
| 334 | + public static function get_pagination($prefs = array()) { |
|
| 335 | 335 | |
| 336 | 336 | global $wp_query; |
| 337 | 337 | global $paged; |
| 338 | 338 | global $wp_rewrite; |
| 339 | 339 | |
| 340 | 340 | $args = array(); |
| 341 | - $args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] ); |
|
| 341 | + $args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']); |
|
| 342 | 342 | |
| 343 | - if ( $wp_rewrite->using_permalinks() ) { |
|
| 343 | + if ($wp_rewrite->using_permalinks()) { |
|
| 344 | 344 | |
| 345 | - $url = explode( '?', get_pagenum_link( 0 ) ); |
|
| 345 | + $url = explode('?', get_pagenum_link(0)); |
|
| 346 | 346 | |
| 347 | - if ( isset( $url[1] ) ) { |
|
| 348 | - parse_str( $url[1], $query ); |
|
| 347 | + if (isset($url[1])) { |
|
| 348 | + parse_str($url[1], $query); |
|
| 349 | 349 | $args['add_args'] = $query; |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | $args['format'] = 'page/%#%'; |
| 353 | - $args['base'] = trailingslashit( $url[0] ).'%_%'; |
|
| 353 | + $args['base'] = trailingslashit($url[0]).'%_%'; |
|
| 354 | 354 | |
| 355 | 355 | } else { |
| 356 | 356 | $big = 999999999; |
| 357 | - $args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); |
|
| 357 | + $args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big))); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | $args['type'] = 'array'; |
| 361 | - $args['current'] = max( 1, get_query_var( 'paged' ) ); |
|
| 362 | - $args['mid_size'] = max( 9 - $args['current'], 3 ); |
|
| 361 | + $args['current'] = max(1, get_query_var('paged')); |
|
| 362 | + $args['mid_size'] = max(9 - $args['current'], 3); |
|
| 363 | 363 | $args['prev_next'] = false; |
| 364 | 364 | |
| 365 | - if ( is_int( $prefs ) ) { |
|
| 365 | + if (is_int($prefs)) { |
|
| 366 | 366 | $args['mid_size'] = $prefs - 2; |
| 367 | 367 | } else { |
| 368 | - $args = array_merge( $args, $prefs ); |
|
| 368 | + $args = array_merge($args, $prefs); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | $data = array(); |
| 372 | - $data['pages'] = Helper::paginate_links( $args ); |
|
| 373 | - $next = get_next_posts_page_link( $args['total'] ); |
|
| 372 | + $data['pages'] = Helper::paginate_links($args); |
|
| 373 | + $next = get_next_posts_page_link($args['total']); |
|
| 374 | 374 | |
| 375 | - if ( $next ) { |
|
| 376 | - $data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' ); |
|
| 375 | + if ($next) { |
|
| 376 | + $data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next'); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - $prev = previous_posts( false ); |
|
| 379 | + $prev = previous_posts(false); |
|
| 380 | 380 | |
| 381 | - if ( $prev ) { |
|
| 382 | - $data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' ); |
|
| 381 | + if ($prev) { |
|
| 382 | + $data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev'); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - if ( $paged < 2 ) { |
|
| 385 | + if ($paged < 2) { |
|
| 386 | 386 | $data['prev'] = null; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - return Helper::array_to_object( $data ); |
|
| 389 | + return Helper::array_to_object($data); |
|
| 390 | 390 | |
| 391 | 391 | } |
| 392 | 392 | } |