@@ -8,83 +8,83 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | // Bookmark hooks. |
| 11 | -add_action( 'admin_page_access_denied', 'wp_link_manager_disabled_message' ); |
|
| 11 | +add_action('admin_page_access_denied', 'wp_link_manager_disabled_message'); |
|
| 12 | 12 | |
| 13 | 13 | // Dashboard hooks. |
| 14 | -add_action( 'activity_box_end', 'wp_dashboard_quota' ); |
|
| 14 | +add_action('activity_box_end', 'wp_dashboard_quota'); |
|
| 15 | 15 | |
| 16 | 16 | // Media hooks. |
| 17 | -add_action( 'attachment_submitbox_misc_actions', 'attachment_submitbox_metadata' ); |
|
| 17 | +add_action('attachment_submitbox_misc_actions', 'attachment_submitbox_metadata'); |
|
| 18 | 18 | |
| 19 | -add_action( 'media_upload_image', 'wp_media_upload_handler' ); |
|
| 20 | -add_action( 'media_upload_audio', 'wp_media_upload_handler' ); |
|
| 21 | -add_action( 'media_upload_video', 'wp_media_upload_handler' ); |
|
| 22 | -add_action( 'media_upload_file', 'wp_media_upload_handler' ); |
|
| 19 | +add_action('media_upload_image', 'wp_media_upload_handler'); |
|
| 20 | +add_action('media_upload_audio', 'wp_media_upload_handler'); |
|
| 21 | +add_action('media_upload_video', 'wp_media_upload_handler'); |
|
| 22 | +add_action('media_upload_file', 'wp_media_upload_handler'); |
|
| 23 | 23 | |
| 24 | -add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ); |
|
| 24 | +add_action('post-plupload-upload-ui', 'media_upload_flash_bypass'); |
|
| 25 | 25 | |
| 26 | -add_action( 'post-html-upload-ui', 'media_upload_html_bypass' ); |
|
| 26 | +add_action('post-html-upload-ui', 'media_upload_html_bypass'); |
|
| 27 | 27 | |
| 28 | -add_filter( 'async_upload_image', 'get_media_item', 10, 2 ); |
|
| 29 | -add_filter( 'async_upload_audio', 'get_media_item', 10, 2 ); |
|
| 30 | -add_filter( 'async_upload_video', 'get_media_item', 10, 2 ); |
|
| 31 | -add_filter( 'async_upload_file', 'get_media_item', 10, 2 ); |
|
| 28 | +add_filter('async_upload_image', 'get_media_item', 10, 2); |
|
| 29 | +add_filter('async_upload_audio', 'get_media_item', 10, 2); |
|
| 30 | +add_filter('async_upload_video', 'get_media_item', 10, 2); |
|
| 31 | +add_filter('async_upload_file', 'get_media_item', 10, 2); |
|
| 32 | 32 | |
| 33 | -add_filter( 'attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2 ); |
|
| 33 | +add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2); |
|
| 34 | 34 | |
| 35 | -add_filter( 'media_upload_gallery', 'media_upload_gallery' ); |
|
| 36 | -add_filter( 'media_upload_library', 'media_upload_library' ); |
|
| 35 | +add_filter('media_upload_gallery', 'media_upload_gallery'); |
|
| 36 | +add_filter('media_upload_library', 'media_upload_library'); |
|
| 37 | 37 | |
| 38 | -add_filter( 'media_upload_tabs', 'update_gallery_tab' ); |
|
| 38 | +add_filter('media_upload_tabs', 'update_gallery_tab'); |
|
| 39 | 39 | |
| 40 | 40 | // Misc hooks. |
| 41 | -add_action( 'admin_head', 'wp_admin_canonical_url' ); |
|
| 42 | -add_action( 'admin_head', 'wp_color_scheme_settings' ); |
|
| 43 | -add_action( 'admin_head', 'wp_site_icon' ); |
|
| 44 | -add_action( 'admin_head', '_ipad_meta' ); |
|
| 41 | +add_action('admin_head', 'wp_admin_canonical_url'); |
|
| 42 | +add_action('admin_head', 'wp_color_scheme_settings'); |
|
| 43 | +add_action('admin_head', 'wp_site_icon'); |
|
| 44 | +add_action('admin_head', '_ipad_meta'); |
|
| 45 | 45 | |
| 46 | 46 | // Prerendering. |
| 47 | -if ( ! is_customize_preview() ) { |
|
| 48 | - add_filter( 'admin_print_styles', 'wp_resource_hints', 1 ); |
|
| 47 | +if ( ! is_customize_preview()) { |
|
| 48 | + add_filter('admin_print_styles', 'wp_resource_hints', 1); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | -add_action( 'admin_print_scripts-post.php', 'wp_page_reload_on_back_button_js' ); |
|
| 52 | -add_action( 'admin_print_scripts-post-new.php', 'wp_page_reload_on_back_button_js' ); |
|
| 51 | +add_action('admin_print_scripts-post.php', 'wp_page_reload_on_back_button_js'); |
|
| 52 | +add_action('admin_print_scripts-post-new.php', 'wp_page_reload_on_back_button_js'); |
|
| 53 | 53 | |
| 54 | -add_action( 'update_option_home', 'update_home_siteurl', 10, 2 ); |
|
| 55 | -add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); |
|
| 56 | -add_action( 'update_option_page_on_front', 'update_home_siteurl', 10, 2 ); |
|
| 54 | +add_action('update_option_home', 'update_home_siteurl', 10, 2); |
|
| 55 | +add_action('update_option_siteurl', 'update_home_siteurl', 10, 2); |
|
| 56 | +add_action('update_option_page_on_front', 'update_home_siteurl', 10, 2); |
|
| 57 | 57 | |
| 58 | -add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 ); |
|
| 59 | -add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 ); |
|
| 60 | -add_filter( 'wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3 ); |
|
| 61 | -add_filter( 'heartbeat_received', 'heartbeat_autosave', 500, 2 ); |
|
| 58 | +add_filter('heartbeat_received', 'wp_check_locked_posts', 10, 3); |
|
| 59 | +add_filter('heartbeat_received', 'wp_refresh_post_lock', 10, 3); |
|
| 60 | +add_filter('wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3); |
|
| 61 | +add_filter('heartbeat_received', 'heartbeat_autosave', 500, 2); |
|
| 62 | 62 | |
| 63 | -add_filter( 'heartbeat_settings', 'wp_heartbeat_set_suspension' ); |
|
| 63 | +add_filter('heartbeat_settings', 'wp_heartbeat_set_suspension'); |
|
| 64 | 64 | |
| 65 | 65 | // Nav Menu hooks. |
| 66 | -add_action( 'admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items' ); |
|
| 66 | +add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items'); |
|
| 67 | 67 | |
| 68 | 68 | // Plugin hooks. |
| 69 | -add_filter( 'whitelist_options', 'option_update_filter' ); |
|
| 69 | +add_filter('whitelist_options', 'option_update_filter'); |
|
| 70 | 70 | |
| 71 | 71 | // Plugin Install hooks. |
| 72 | -add_action( 'install_plugins_featured', 'install_dashboard' ); |
|
| 73 | -add_action( 'install_plugins_upload', 'install_plugins_upload' ); |
|
| 74 | -add_action( 'install_plugins_search', 'display_plugins_table' ); |
|
| 75 | -add_action( 'install_plugins_popular', 'display_plugins_table' ); |
|
| 76 | -add_action( 'install_plugins_recommended', 'display_plugins_table' ); |
|
| 77 | -add_action( 'install_plugins_new', 'display_plugins_table' ); |
|
| 78 | -add_action( 'install_plugins_beta', 'display_plugins_table' ); |
|
| 79 | -add_action( 'install_plugins_favorites', 'display_plugins_table' ); |
|
| 80 | -add_action( 'install_plugins_pre_plugin-information', 'install_plugin_information' ); |
|
| 72 | +add_action('install_plugins_featured', 'install_dashboard'); |
|
| 73 | +add_action('install_plugins_upload', 'install_plugins_upload'); |
|
| 74 | +add_action('install_plugins_search', 'display_plugins_table'); |
|
| 75 | +add_action('install_plugins_popular', 'display_plugins_table'); |
|
| 76 | +add_action('install_plugins_recommended', 'display_plugins_table'); |
|
| 77 | +add_action('install_plugins_new', 'display_plugins_table'); |
|
| 78 | +add_action('install_plugins_beta', 'display_plugins_table'); |
|
| 79 | +add_action('install_plugins_favorites', 'display_plugins_table'); |
|
| 80 | +add_action('install_plugins_pre_plugin-information', 'install_plugin_information'); |
|
| 81 | 81 | |
| 82 | 82 | // Template hooks. |
| 83 | -add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) ); |
|
| 84 | -add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) ); |
|
| 83 | +add_action('admin_enqueue_scripts', array('WP_Internal_Pointers', 'enqueue_scripts')); |
|
| 84 | +add_action('user_register', array('WP_Internal_Pointers', 'dismiss_pointers_for_new_users')); |
|
| 85 | 85 | |
| 86 | 86 | // Theme hooks. |
| 87 | -add_action( 'customize_controls_print_footer_scripts', 'customize_themes_print_templates' ); |
|
| 87 | +add_action('customize_controls_print_footer_scripts', 'customize_themes_print_templates'); |
|
| 88 | 88 | |
| 89 | 89 | // Theme Install hooks. |
| 90 | 90 | // add_action('install_themes_dashboard', 'install_themes_dashboard'); |
@@ -93,29 +93,29 @@ discard block |
||
| 93 | 93 | // add_action('install_themes_featured', 'display_themes'); |
| 94 | 94 | // add_action('install_themes_new', 'display_themes'); |
| 95 | 95 | // add_action('install_themes_updated', 'display_themes'); |
| 96 | -add_action( 'install_themes_pre_theme-information', 'install_theme_information' ); |
|
| 96 | +add_action('install_themes_pre_theme-information', 'install_theme_information'); |
|
| 97 | 97 | |
| 98 | 98 | // User hooks. |
| 99 | -add_action( 'admin_init', 'default_password_nag_handler' ); |
|
| 99 | +add_action('admin_init', 'default_password_nag_handler'); |
|
| 100 | 100 | |
| 101 | -add_action( 'admin_notices', 'default_password_nag' ); |
|
| 101 | +add_action('admin_notices', 'default_password_nag'); |
|
| 102 | 102 | |
| 103 | -add_action( 'profile_update', 'default_password_nag_edit_user', 10, 2 ); |
|
| 103 | +add_action('profile_update', 'default_password_nag_edit_user', 10, 2); |
|
| 104 | 104 | |
| 105 | 105 | // Update hooks. |
| 106 | -add_action( 'load-plugins.php', 'wp_plugin_update_rows', 20 ); // After wp_update_plugins() is called. |
|
| 107 | -add_action( 'load-themes.php', 'wp_theme_update_rows', 20 ); // After wp_update_themes() is called. |
|
| 106 | +add_action('load-plugins.php', 'wp_plugin_update_rows', 20); // After wp_update_plugins() is called. |
|
| 107 | +add_action('load-themes.php', 'wp_theme_update_rows', 20); // After wp_update_themes() is called. |
|
| 108 | 108 | |
| 109 | -add_action( 'admin_notices', 'update_nag', 3 ); |
|
| 110 | -add_action( 'admin_notices', 'maintenance_nag', 10 ); |
|
| 109 | +add_action('admin_notices', 'update_nag', 3); |
|
| 110 | +add_action('admin_notices', 'maintenance_nag', 10); |
|
| 111 | 111 | |
| 112 | -add_filter( 'update_footer', 'core_update_footer' ); |
|
| 112 | +add_filter('update_footer', 'core_update_footer'); |
|
| 113 | 113 | |
| 114 | 114 | // Update Core hooks. |
| 115 | -add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' ); |
|
| 115 | +add_action('_core_updated_successfully', '_redirect_to_about_wordpress'); |
|
| 116 | 116 | |
| 117 | 117 | // Upgrade hooks. |
| 118 | -add_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); |
|
| 119 | -add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 ); |
|
| 120 | -add_action( 'upgrader_process_complete', 'wp_update_plugins', 10, 0 ); |
|
| 121 | -add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 ); |
|
| 118 | +add_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20); |
|
| 119 | +add_action('upgrader_process_complete', 'wp_version_check', 10, 0); |
|
| 120 | +add_action('upgrader_process_complete', 'wp_update_plugins', 10, 0); |
|
| 121 | +add_action('upgrader_process_complete', 'wp_update_themes', 10, 0); |
|
@@ -22,44 +22,44 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @param array $opt |
| 24 | 24 | */ |
| 25 | - public function __construct( $opt = '' ) { |
|
| 25 | + public function __construct($opt = '') { |
|
| 26 | 26 | $this->method = 'ftpext'; |
| 27 | 27 | $this->errors = new WP_Error(); |
| 28 | 28 | |
| 29 | 29 | // Check if possible to use ftp functions. |
| 30 | - if ( ! extension_loaded('ftp') ) { |
|
| 30 | + if ( ! extension_loaded('ftp')) { |
|
| 31 | 31 | $this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available')); |
| 32 | 32 | return; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // This Class uses the timeout on a per-connection basis, Others use it on a per-action basis. |
| 36 | 36 | |
| 37 | - if ( ! defined('FS_TIMEOUT') ) |
|
| 37 | + if ( ! defined('FS_TIMEOUT')) |
|
| 38 | 38 | define('FS_TIMEOUT', 240); |
| 39 | 39 | |
| 40 | - if ( empty($opt['port']) ) |
|
| 40 | + if (empty($opt['port'])) |
|
| 41 | 41 | $this->options['port'] = 21; |
| 42 | 42 | else |
| 43 | 43 | $this->options['port'] = $opt['port']; |
| 44 | 44 | |
| 45 | - if ( empty($opt['hostname']) ) |
|
| 45 | + if (empty($opt['hostname'])) |
|
| 46 | 46 | $this->errors->add('empty_hostname', __('FTP hostname is required')); |
| 47 | 47 | else |
| 48 | 48 | $this->options['hostname'] = $opt['hostname']; |
| 49 | 49 | |
| 50 | 50 | // Check if the options provided are OK. |
| 51 | - if ( empty($opt['username']) ) |
|
| 51 | + if (empty($opt['username'])) |
|
| 52 | 52 | $this->errors->add('empty_username', __('FTP username is required')); |
| 53 | 53 | else |
| 54 | 54 | $this->options['username'] = $opt['username']; |
| 55 | 55 | |
| 56 | - if ( empty($opt['password']) ) |
|
| 56 | + if (empty($opt['password'])) |
|
| 57 | 57 | $this->errors->add('empty_password', __('FTP password is required')); |
| 58 | 58 | else |
| 59 | 59 | $this->options['password'] = $opt['password']; |
| 60 | 60 | |
| 61 | 61 | $this->options['ssl'] = false; |
| 62 | - if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] ) |
|
| 62 | + if (isset($opt['connection_type']) && 'ftps' == $opt['connection_type']) |
|
| 63 | 63 | $this->options['ssl'] = true; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -69,25 +69,25 @@ discard block |
||
| 69 | 69 | * @return bool |
| 70 | 70 | */ |
| 71 | 71 | public function connect() { |
| 72 | - if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') ) |
|
| 72 | + if (isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect')) |
|
| 73 | 73 | $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT); |
| 74 | 74 | else |
| 75 | 75 | $this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT); |
| 76 | 76 | |
| 77 | - if ( ! $this->link ) { |
|
| 78 | - $this->errors->add( 'connect', |
|
| 77 | + if ( ! $this->link) { |
|
| 78 | + $this->errors->add('connect', |
|
| 79 | 79 | /* translators: %s: hostname:port */ |
| 80 | - sprintf( __( 'Failed to connect to FTP Server %s' ), |
|
| 81 | - $this->options['hostname'] . ':' . $this->options['port'] |
|
| 80 | + sprintf(__('Failed to connect to FTP Server %s'), |
|
| 81 | + $this->options['hostname'].':'.$this->options['port'] |
|
| 82 | 82 | ) |
| 83 | 83 | ); |
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if ( ! @ftp_login( $this->link,$this->options['username'], $this->options['password'] ) ) { |
|
| 88 | - $this->errors->add( 'auth', |
|
| 87 | + if ( ! @ftp_login($this->link, $this->options['username'], $this->options['password'])) { |
|
| 88 | + $this->errors->add('auth', |
|
| 89 | 89 | /* translators: %s: username */ |
| 90 | - sprintf( __( 'Username/Password incorrect for %s' ), |
|
| 90 | + sprintf(__('Username/Password incorrect for %s'), |
|
| 91 | 91 | $this->options['username'] |
| 92 | 92 | ) |
| 93 | 93 | ); |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | // Set the Connection to use Passive FTP |
| 98 | - @ftp_pasv( $this->link, true ); |
|
| 99 | - if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT ) |
|
| 98 | + @ftp_pasv($this->link, true); |
|
| 99 | + if (@ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT) |
|
| 100 | 100 | @ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT); |
| 101 | 101 | |
| 102 | 102 | return true; |
@@ -112,25 +112,25 @@ discard block |
||
| 112 | 112 | * @return string|false File contents on success, false if no temp file could be opened, |
| 113 | 113 | * or if the file couldn't be retrieved. |
| 114 | 114 | */ |
| 115 | - public function get_contents( $file ) { |
|
| 115 | + public function get_contents($file) { |
|
| 116 | 116 | $tempfile = wp_tempnam($file); |
| 117 | 117 | $temp = fopen($tempfile, 'w+'); |
| 118 | 118 | |
| 119 | - if ( ! $temp ) { |
|
| 120 | - unlink( $tempfile ); |
|
| 119 | + if ( ! $temp) { |
|
| 120 | + unlink($tempfile); |
|
| 121 | 121 | return false; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if ( ! @ftp_fget( $this->link, $temp, $file, FTP_BINARY ) ) { |
|
| 125 | - fclose( $temp ); |
|
| 126 | - unlink( $tempfile ); |
|
| 124 | + if ( ! @ftp_fget($this->link, $temp, $file, FTP_BINARY)) { |
|
| 125 | + fclose($temp); |
|
| 126 | + unlink($tempfile); |
|
| 127 | 127 | return false; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - fseek( $temp, 0 ); // Skip back to the start of the file being written to |
|
| 130 | + fseek($temp, 0); // Skip back to the start of the file being written to |
|
| 131 | 131 | $contents = ''; |
| 132 | 132 | |
| 133 | - while ( ! feof($temp) ) |
|
| 133 | + while ( ! feof($temp)) |
|
| 134 | 134 | $contents .= fread($temp, 8192); |
| 135 | 135 | |
| 136 | 136 | fclose($temp); |
@@ -156,31 +156,31 @@ discard block |
||
| 156 | 156 | * @param bool|int $mode |
| 157 | 157 | * @return bool |
| 158 | 158 | */ |
| 159 | - public function put_contents($file, $contents, $mode = false ) { |
|
| 159 | + public function put_contents($file, $contents, $mode = false) { |
|
| 160 | 160 | $tempfile = wp_tempnam($file); |
| 161 | - $temp = fopen( $tempfile, 'wb+' ); |
|
| 161 | + $temp = fopen($tempfile, 'wb+'); |
|
| 162 | 162 | |
| 163 | - if ( ! $temp ) { |
|
| 164 | - unlink( $tempfile ); |
|
| 163 | + if ( ! $temp) { |
|
| 164 | + unlink($tempfile); |
|
| 165 | 165 | return false; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | mbstring_binary_safe_encoding(); |
| 169 | 169 | |
| 170 | - $data_length = strlen( $contents ); |
|
| 171 | - $bytes_written = fwrite( $temp, $contents ); |
|
| 170 | + $data_length = strlen($contents); |
|
| 171 | + $bytes_written = fwrite($temp, $contents); |
|
| 172 | 172 | |
| 173 | 173 | reset_mbstring_encoding(); |
| 174 | 174 | |
| 175 | - if ( $data_length !== $bytes_written ) { |
|
| 176 | - fclose( $temp ); |
|
| 177 | - unlink( $tempfile ); |
|
| 175 | + if ($data_length !== $bytes_written) { |
|
| 176 | + fclose($temp); |
|
| 177 | + unlink($tempfile); |
|
| 178 | 178 | return false; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - fseek( $temp, 0 ); // Skip back to the start of the file being written to |
|
| 181 | + fseek($temp, 0); // Skip back to the start of the file being written to |
|
| 182 | 182 | |
| 183 | - $ret = @ftp_fput( $this->link, $file, $temp, FTP_BINARY ); |
|
| 183 | + $ret = @ftp_fput($this->link, $file, $temp, FTP_BINARY); |
|
| 184 | 184 | |
| 185 | 185 | fclose($temp); |
| 186 | 186 | unlink($tempfile); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | public function cwd() { |
| 199 | 199 | $cwd = @ftp_pwd($this->link); |
| 200 | - if ( $cwd ) |
|
| 200 | + if ($cwd) |
|
| 201 | 201 | $cwd = trailingslashit($cwd); |
| 202 | 202 | return $cwd; |
| 203 | 203 | } |
@@ -221,26 +221,26 @@ discard block |
||
| 221 | 221 | * @return bool |
| 222 | 222 | */ |
| 223 | 223 | public function chmod($file, $mode = false, $recursive = false) { |
| 224 | - if ( ! $mode ) { |
|
| 225 | - if ( $this->is_file($file) ) |
|
| 224 | + if ( ! $mode) { |
|
| 225 | + if ($this->is_file($file)) |
|
| 226 | 226 | $mode = FS_CHMOD_FILE; |
| 227 | - elseif ( $this->is_dir($file) ) |
|
| 227 | + elseif ($this->is_dir($file)) |
|
| 228 | 228 | $mode = FS_CHMOD_DIR; |
| 229 | 229 | else |
| 230 | 230 | return false; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // chmod any sub-objects if recursive. |
| 234 | - if ( $recursive && $this->is_dir($file) ) { |
|
| 234 | + if ($recursive && $this->is_dir($file)) { |
|
| 235 | 235 | $filelist = $this->dirlist($file); |
| 236 | - foreach ( (array)$filelist as $filename => $filemeta ) |
|
| 237 | - $this->chmod($file . '/' . $filename, $mode, $recursive); |
|
| 236 | + foreach ((array) $filelist as $filename => $filemeta) |
|
| 237 | + $this->chmod($file.'/'.$filename, $mode, $recursive); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // chmod the file or directory |
| 241 | - if ( ! function_exists('ftp_chmod') ) |
|
| 242 | - return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); |
|
| 243 | - return (bool)@ftp_chmod($this->link, $mode, $file); |
|
| 241 | + if ( ! function_exists('ftp_chmod')) |
|
| 242 | + return (bool) @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); |
|
| 243 | + return (bool) @ftp_chmod($this->link, $mode, $file); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -285,10 +285,10 @@ discard block |
||
| 285 | 285 | * @return bool |
| 286 | 286 | */ |
| 287 | 287 | public function copy($source, $destination, $overwrite = false, $mode = false) { |
| 288 | - if ( ! $overwrite && $this->exists($destination) ) |
|
| 288 | + if ( ! $overwrite && $this->exists($destination)) |
|
| 289 | 289 | return false; |
| 290 | 290 | $content = $this->get_contents($source); |
| 291 | - if ( false === $content ) |
|
| 291 | + if (false === $content) |
|
| 292 | 292 | return false; |
| 293 | 293 | return $this->put_contents($destination, $content, $mode); |
| 294 | 294 | } |
@@ -314,17 +314,17 @@ discard block |
||
| 314 | 314 | * @return bool |
| 315 | 315 | */ |
| 316 | 316 | public function delete($file, $recursive = false, $type = false) { |
| 317 | - if ( empty($file) ) |
|
| 317 | + if (empty($file)) |
|
| 318 | 318 | return false; |
| 319 | - if ( 'f' == $type || $this->is_file($file) ) |
|
| 319 | + if ('f' == $type || $this->is_file($file)) |
|
| 320 | 320 | return @ftp_delete($this->link, $file); |
| 321 | - if ( !$recursive ) |
|
| 321 | + if ( ! $recursive) |
|
| 322 | 322 | return @ftp_rmdir($this->link, $file); |
| 323 | 323 | |
| 324 | - $filelist = $this->dirlist( trailingslashit($file) ); |
|
| 325 | - if ( !empty($filelist) ) |
|
| 326 | - foreach ( $filelist as $delete_file ) |
|
| 327 | - $this->delete( trailingslashit($file) . $delete_file['name'], $recursive, $delete_file['type'] ); |
|
| 324 | + $filelist = $this->dirlist(trailingslashit($file)); |
|
| 325 | + if ( ! empty($filelist)) |
|
| 326 | + foreach ($filelist as $delete_file) |
|
| 327 | + $this->delete(trailingslashit($file).$delete_file['name'], $recursive, $delete_file['type']); |
|
| 328 | 328 | return @ftp_rmdir($this->link, $file); |
| 329 | 329 | } |
| 330 | 330 | |
@@ -337,11 +337,11 @@ discard block |
||
| 337 | 337 | public function exists($file) { |
| 338 | 338 | $list = @ftp_nlist($this->link, $file); |
| 339 | 339 | |
| 340 | - if ( empty( $list ) && $this->is_dir( $file ) ) { |
|
| 340 | + if (empty($list) && $this->is_dir($file)) { |
|
| 341 | 341 | return true; // File is an empty directory. |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - return !empty($list); //empty list = no file, so invert. |
|
| 344 | + return ! empty($list); //empty list = no file, so invert. |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | * @return bool |
| 352 | 352 | */ |
| 353 | 353 | public function is_file($file) { |
| 354 | - return $this->exists($file) && !$this->is_dir($file); |
|
| 354 | + return $this->exists($file) && ! $this->is_dir($file); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | /** |
@@ -362,8 +362,8 @@ discard block |
||
| 362 | 362 | */ |
| 363 | 363 | public function is_dir($path) { |
| 364 | 364 | $cwd = $this->cwd(); |
| 365 | - $result = @ftp_chdir($this->link, trailingslashit($path) ); |
|
| 366 | - if ( $result && $path == $this->cwd() || $this->cwd() != $cwd ) { |
|
| 365 | + $result = @ftp_chdir($this->link, trailingslashit($path)); |
|
| 366 | + if ($result && $path == $this->cwd() || $this->cwd() != $cwd) { |
|
| 367 | 367 | @ftp_chdir($this->link, $cwd); |
| 368 | 368 | return true; |
| 369 | 369 | } |
@@ -441,10 +441,10 @@ discard block |
||
| 441 | 441 | */ |
| 442 | 442 | public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { |
| 443 | 443 | $path = untrailingslashit($path); |
| 444 | - if ( empty($path) ) |
|
| 444 | + if (empty($path)) |
|
| 445 | 445 | return false; |
| 446 | 446 | |
| 447 | - if ( !@ftp_mkdir($this->link, $path) ) |
|
| 447 | + if ( ! @ftp_mkdir($this->link, $path)) |
|
| 448 | 448 | return false; |
| 449 | 449 | $this->chmod($path, $chmod); |
| 450 | 450 | return true; |
@@ -470,17 +470,17 @@ discard block |
||
| 470 | 470 | */ |
| 471 | 471 | public function parselisting($line) { |
| 472 | 472 | static $is_windows = null; |
| 473 | - if ( is_null($is_windows) ) |
|
| 474 | - $is_windows = stripos( ftp_systype($this->link), 'win') !== false; |
|
| 473 | + if (is_null($is_windows)) |
|
| 474 | + $is_windows = stripos(ftp_systype($this->link), 'win') !== false; |
|
| 475 | 475 | |
| 476 | - if ( $is_windows && preg_match('/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/', $line, $lucifer) ) { |
|
| 476 | + if ($is_windows && preg_match('/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/', $line, $lucifer)) { |
|
| 477 | 477 | $b = array(); |
| 478 | - if ( $lucifer[3] < 70 ) |
|
| 479 | - $lucifer[3] +=2000; |
|
| 478 | + if ($lucifer[3] < 70) |
|
| 479 | + $lucifer[3] += 2000; |
|
| 480 | 480 | else |
| 481 | 481 | $lucifer[3] += 1900; // 4digit year fix |
| 482 | - $b['isdir'] = ( $lucifer[7] == '<DIR>'); |
|
| 483 | - if ( $b['isdir'] ) |
|
| 482 | + $b['isdir'] = ($lucifer[7] == '<DIR>'); |
|
| 483 | + if ($b['isdir']) |
|
| 484 | 484 | $b['type'] = 'd'; |
| 485 | 485 | else |
| 486 | 486 | $b['type'] = 'f'; |
@@ -493,27 +493,27 @@ discard block |
||
| 493 | 493 | $b['time'] = @mktime($lucifer[4] + (strcasecmp($lucifer[6], "PM") == 0 ? 12 : 0), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3]); |
| 494 | 494 | $b['am/pm'] = $lucifer[6]; |
| 495 | 495 | $b['name'] = $lucifer[8]; |
| 496 | - } elseif ( !$is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) { |
|
| 496 | + } elseif ( ! $is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) { |
|
| 497 | 497 | //echo $line."\n"; |
| 498 | 498 | $lcount = count($lucifer); |
| 499 | - if ( $lcount < 8 ) |
|
| 499 | + if ($lcount < 8) |
|
| 500 | 500 | return ''; |
| 501 | 501 | $b = array(); |
| 502 | 502 | $b['isdir'] = $lucifer[0]{0} === 'd'; |
| 503 | 503 | $b['islink'] = $lucifer[0]{0} === 'l'; |
| 504 | - if ( $b['isdir'] ) |
|
| 504 | + if ($b['isdir']) |
|
| 505 | 505 | $b['type'] = 'd'; |
| 506 | - elseif ( $b['islink'] ) |
|
| 506 | + elseif ($b['islink']) |
|
| 507 | 507 | $b['type'] = 'l'; |
| 508 | 508 | else |
| 509 | 509 | $b['type'] = 'f'; |
| 510 | 510 | $b['perms'] = $lucifer[0]; |
| 511 | - $b['permsn'] = $this->getnumchmodfromh( $b['perms'] ); |
|
| 511 | + $b['permsn'] = $this->getnumchmodfromh($b['perms']); |
|
| 512 | 512 | $b['number'] = $lucifer[1]; |
| 513 | 513 | $b['owner'] = $lucifer[2]; |
| 514 | 514 | $b['group'] = $lucifer[3]; |
| 515 | 515 | $b['size'] = $lucifer[4]; |
| 516 | - if ( $lcount == 8 ) { |
|
| 516 | + if ($lcount == 8) { |
|
| 517 | 517 | sscanf($lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day']); |
| 518 | 518 | sscanf($lucifer[6], '%d:%d', $b['hour'], $b['minute']); |
| 519 | 519 | $b['time'] = @mktime($b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year']); |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | } else { |
| 522 | 522 | $b['month'] = $lucifer[5]; |
| 523 | 523 | $b['day'] = $lucifer[6]; |
| 524 | - if ( preg_match('/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2) ) { |
|
| 524 | + if (preg_match('/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2)) { |
|
| 525 | 525 | $b['year'] = date("Y"); |
| 526 | 526 | $b['hour'] = $l2[1]; |
| 527 | 527 | $b['minute'] = $l2[2]; |
@@ -530,14 +530,14 @@ discard block |
||
| 530 | 530 | $b['hour'] = 0; |
| 531 | 531 | $b['minute'] = 0; |
| 532 | 532 | } |
| 533 | - $b['time'] = strtotime( sprintf('%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute']) ); |
|
| 533 | + $b['time'] = strtotime(sprintf('%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute'])); |
|
| 534 | 534 | $b['name'] = $lucifer[8]; |
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | // Replace symlinks formatted as "source -> target" with just the source name |
| 539 | - if ( isset( $b['islink'] ) && $b['islink'] ) { |
|
| 540 | - $b['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $b['name'] ); |
|
| 539 | + if (isset($b['islink']) && $b['islink']) { |
|
| 540 | + $b['name'] = preg_replace('/(\s*->\s*.*)$/', '', $b['name']); |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | return $b; |
@@ -552,50 +552,50 @@ discard block |
||
| 552 | 552 | * @return bool|array |
| 553 | 553 | */ |
| 554 | 554 | public function dirlist($path = '.', $include_hidden = true, $recursive = false) { |
| 555 | - if ( $this->is_file($path) ) { |
|
| 555 | + if ($this->is_file($path)) { |
|
| 556 | 556 | $limit_file = basename($path); |
| 557 | - $path = dirname($path) . '/'; |
|
| 557 | + $path = dirname($path).'/'; |
|
| 558 | 558 | } else { |
| 559 | 559 | $limit_file = false; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | $pwd = @ftp_pwd($this->link); |
| 563 | - if ( ! @ftp_chdir($this->link, $path) ) // Cant change to folder = folder doesn't exist |
|
| 563 | + if ( ! @ftp_chdir($this->link, $path)) // Cant change to folder = folder doesn't exist |
|
| 564 | 564 | return false; |
| 565 | 565 | $list = @ftp_rawlist($this->link, '-a', false); |
| 566 | 566 | @ftp_chdir($this->link, $pwd); |
| 567 | 567 | |
| 568 | - if ( empty($list) ) // Empty array = non-existent folder (real folder will show . at least) |
|
| 568 | + if (empty($list)) // Empty array = non-existent folder (real folder will show . at least) |
|
| 569 | 569 | return false; |
| 570 | 570 | |
| 571 | 571 | $dirlist = array(); |
| 572 | - foreach ( $list as $k => $v ) { |
|
| 572 | + foreach ($list as $k => $v) { |
|
| 573 | 573 | $entry = $this->parselisting($v); |
| 574 | - if ( empty($entry) ) |
|
| 574 | + if (empty($entry)) |
|
| 575 | 575 | continue; |
| 576 | 576 | |
| 577 | - if ( '.' == $entry['name'] || '..' == $entry['name'] ) |
|
| 577 | + if ('.' == $entry['name'] || '..' == $entry['name']) |
|
| 578 | 578 | continue; |
| 579 | 579 | |
| 580 | - if ( ! $include_hidden && '.' == $entry['name'][0] ) |
|
| 580 | + if ( ! $include_hidden && '.' == $entry['name'][0]) |
|
| 581 | 581 | continue; |
| 582 | 582 | |
| 583 | - if ( $limit_file && $entry['name'] != $limit_file) |
|
| 583 | + if ($limit_file && $entry['name'] != $limit_file) |
|
| 584 | 584 | continue; |
| 585 | 585 | |
| 586 | - $dirlist[ $entry['name'] ] = $entry; |
|
| 586 | + $dirlist[$entry['name']] = $entry; |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | $ret = array(); |
| 590 | - foreach ( (array)$dirlist as $struc ) { |
|
| 591 | - if ( 'd' == $struc['type'] ) { |
|
| 592 | - if ( $recursive ) |
|
| 593 | - $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive); |
|
| 590 | + foreach ((array) $dirlist as $struc) { |
|
| 591 | + if ('d' == $struc['type']) { |
|
| 592 | + if ($recursive) |
|
| 593 | + $struc['files'] = $this->dirlist($path.'/'.$struc['name'], $include_hidden, $recursive); |
|
| 594 | 594 | else |
| 595 | 595 | $struc['files'] = array(); |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - $ret[ $struc['name'] ] = $struc; |
|
| 598 | + $ret[$struc['name']] = $struc; |
|
| 599 | 599 | } |
| 600 | 600 | return $ret; |
| 601 | 601 | } |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @access public |
| 605 | 605 | */ |
| 606 | 606 | public function __destruct() { |
| 607 | - if ( $this->link ) |
|
| 607 | + if ($this->link) |
|
| 608 | 608 | ftp_close($this->link); |
| 609 | 609 | } |
| 610 | 610 | } |
@@ -34,33 +34,39 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | // This Class uses the timeout on a per-connection basis, Others use it on a per-action basis. |
| 36 | 36 | |
| 37 | - if ( ! defined('FS_TIMEOUT') ) |
|
| 38 | - define('FS_TIMEOUT', 240); |
|
| 37 | + if ( ! defined('FS_TIMEOUT') ) { |
|
| 38 | + define('FS_TIMEOUT', 240); |
|
| 39 | + } |
|
| 39 | 40 | |
| 40 | - if ( empty($opt['port']) ) |
|
| 41 | - $this->options['port'] = 21; |
|
| 42 | - else |
|
| 43 | - $this->options['port'] = $opt['port']; |
|
| 41 | + if ( empty($opt['port']) ) { |
|
| 42 | + $this->options['port'] = 21; |
|
| 43 | + } else { |
|
| 44 | + $this->options['port'] = $opt['port']; |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | - if ( empty($opt['hostname']) ) |
|
| 46 | - $this->errors->add('empty_hostname', __('FTP hostname is required')); |
|
| 47 | - else |
|
| 48 | - $this->options['hostname'] = $opt['hostname']; |
|
| 47 | + if ( empty($opt['hostname']) ) { |
|
| 48 | + $this->errors->add('empty_hostname', __('FTP hostname is required')); |
|
| 49 | + } else { |
|
| 50 | + $this->options['hostname'] = $opt['hostname']; |
|
| 51 | + } |
|
| 49 | 52 | |
| 50 | 53 | // Check if the options provided are OK. |
| 51 | - if ( empty($opt['username']) ) |
|
| 52 | - $this->errors->add('empty_username', __('FTP username is required')); |
|
| 53 | - else |
|
| 54 | - $this->options['username'] = $opt['username']; |
|
| 54 | + if ( empty($opt['username']) ) { |
|
| 55 | + $this->errors->add('empty_username', __('FTP username is required')); |
|
| 56 | + } else { |
|
| 57 | + $this->options['username'] = $opt['username']; |
|
| 58 | + } |
|
| 55 | 59 | |
| 56 | - if ( empty($opt['password']) ) |
|
| 57 | - $this->errors->add('empty_password', __('FTP password is required')); |
|
| 58 | - else |
|
| 59 | - $this->options['password'] = $opt['password']; |
|
| 60 | + if ( empty($opt['password']) ) { |
|
| 61 | + $this->errors->add('empty_password', __('FTP password is required')); |
|
| 62 | + } else { |
|
| 63 | + $this->options['password'] = $opt['password']; |
|
| 64 | + } |
|
| 60 | 65 | |
| 61 | 66 | $this->options['ssl'] = false; |
| 62 | - if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] ) |
|
| 63 | - $this->options['ssl'] = true; |
|
| 67 | + if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] ) { |
|
| 68 | + $this->options['ssl'] = true; |
|
| 69 | + } |
|
| 64 | 70 | } |
| 65 | 71 | |
| 66 | 72 | /** |
@@ -69,10 +75,11 @@ discard block |
||
| 69 | 75 | * @return bool |
| 70 | 76 | */ |
| 71 | 77 | public function connect() { |
| 72 | - if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') ) |
|
| 73 | - $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT); |
|
| 74 | - else |
|
| 75 | - $this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT); |
|
| 78 | + if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') ) { |
|
| 79 | + $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT); |
|
| 80 | + } else { |
|
| 81 | + $this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT); |
|
| 82 | + } |
|
| 76 | 83 | |
| 77 | 84 | if ( ! $this->link ) { |
| 78 | 85 | $this->errors->add( 'connect', |
@@ -96,8 +103,9 @@ discard block |
||
| 96 | 103 | |
| 97 | 104 | // Set the Connection to use Passive FTP |
| 98 | 105 | @ftp_pasv( $this->link, true ); |
| 99 | - if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT ) |
|
| 100 | - @ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT); |
|
| 106 | + if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT ) { |
|
| 107 | + @ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT); |
|
| 108 | + } |
|
| 101 | 109 | |
| 102 | 110 | return true; |
| 103 | 111 | } |
@@ -130,8 +138,9 @@ discard block |
||
| 130 | 138 | fseek( $temp, 0 ); // Skip back to the start of the file being written to |
| 131 | 139 | $contents = ''; |
| 132 | 140 | |
| 133 | - while ( ! feof($temp) ) |
|
| 134 | - $contents .= fread($temp, 8192); |
|
| 141 | + while ( ! feof($temp) ) { |
|
| 142 | + $contents .= fread($temp, 8192); |
|
| 143 | + } |
|
| 135 | 144 | |
| 136 | 145 | fclose($temp); |
| 137 | 146 | unlink($tempfile); |
@@ -197,8 +206,9 @@ discard block |
||
| 197 | 206 | */ |
| 198 | 207 | public function cwd() { |
| 199 | 208 | $cwd = @ftp_pwd($this->link); |
| 200 | - if ( $cwd ) |
|
| 201 | - $cwd = trailingslashit($cwd); |
|
| 209 | + if ( $cwd ) { |
|
| 210 | + $cwd = trailingslashit($cwd); |
|
| 211 | + } |
|
| 202 | 212 | return $cwd; |
| 203 | 213 | } |
| 204 | 214 | |
@@ -222,24 +232,27 @@ discard block |
||
| 222 | 232 | */ |
| 223 | 233 | public function chmod($file, $mode = false, $recursive = false) { |
| 224 | 234 | if ( ! $mode ) { |
| 225 | - if ( $this->is_file($file) ) |
|
| 226 | - $mode = FS_CHMOD_FILE; |
|
| 227 | - elseif ( $this->is_dir($file) ) |
|
| 228 | - $mode = FS_CHMOD_DIR; |
|
| 229 | - else |
|
| 230 | - return false; |
|
| 235 | + if ( $this->is_file($file) ) { |
|
| 236 | + $mode = FS_CHMOD_FILE; |
|
| 237 | + } elseif ( $this->is_dir($file) ) { |
|
| 238 | + $mode = FS_CHMOD_DIR; |
|
| 239 | + } else { |
|
| 240 | + return false; |
|
| 241 | + } |
|
| 231 | 242 | } |
| 232 | 243 | |
| 233 | 244 | // chmod any sub-objects if recursive. |
| 234 | 245 | if ( $recursive && $this->is_dir($file) ) { |
| 235 | 246 | $filelist = $this->dirlist($file); |
| 236 | - foreach ( (array)$filelist as $filename => $filemeta ) |
|
| 237 | - $this->chmod($file . '/' . $filename, $mode, $recursive); |
|
| 247 | + foreach ( (array)$filelist as $filename => $filemeta ) { |
|
| 248 | + $this->chmod($file . '/' . $filename, $mode, $recursive); |
|
| 249 | + } |
|
| 238 | 250 | } |
| 239 | 251 | |
| 240 | 252 | // chmod the file or directory |
| 241 | - if ( ! function_exists('ftp_chmod') ) |
|
| 242 | - return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); |
|
| 253 | + if ( ! function_exists('ftp_chmod') ) { |
|
| 254 | + return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); |
|
| 255 | + } |
|
| 243 | 256 | return (bool)@ftp_chmod($this->link, $mode, $file); |
| 244 | 257 | } |
| 245 | 258 | |
@@ -285,11 +298,13 @@ discard block |
||
| 285 | 298 | * @return bool |
| 286 | 299 | */ |
| 287 | 300 | public function copy($source, $destination, $overwrite = false, $mode = false) { |
| 288 | - if ( ! $overwrite && $this->exists($destination) ) |
|
| 289 | - return false; |
|
| 301 | + if ( ! $overwrite && $this->exists($destination) ) { |
|
| 302 | + return false; |
|
| 303 | + } |
|
| 290 | 304 | $content = $this->get_contents($source); |
| 291 | - if ( false === $content ) |
|
| 292 | - return false; |
|
| 305 | + if ( false === $content ) { |
|
| 306 | + return false; |
|
| 307 | + } |
|
| 293 | 308 | return $this->put_contents($destination, $content, $mode); |
| 294 | 309 | } |
| 295 | 310 | |
@@ -314,17 +329,21 @@ discard block |
||
| 314 | 329 | * @return bool |
| 315 | 330 | */ |
| 316 | 331 | public function delete($file, $recursive = false, $type = false) { |
| 317 | - if ( empty($file) ) |
|
| 318 | - return false; |
|
| 319 | - if ( 'f' == $type || $this->is_file($file) ) |
|
| 320 | - return @ftp_delete($this->link, $file); |
|
| 321 | - if ( !$recursive ) |
|
| 322 | - return @ftp_rmdir($this->link, $file); |
|
| 332 | + if ( empty($file) ) { |
|
| 333 | + return false; |
|
| 334 | + } |
|
| 335 | + if ( 'f' == $type || $this->is_file($file) ) { |
|
| 336 | + return @ftp_delete($this->link, $file); |
|
| 337 | + } |
|
| 338 | + if ( !$recursive ) { |
|
| 339 | + return @ftp_rmdir($this->link, $file); |
|
| 340 | + } |
|
| 323 | 341 | |
| 324 | 342 | $filelist = $this->dirlist( trailingslashit($file) ); |
| 325 | - if ( !empty($filelist) ) |
|
| 326 | - foreach ( $filelist as $delete_file ) |
|
| 343 | + if ( !empty($filelist) ) { |
|
| 344 | + foreach ( $filelist as $delete_file ) |
|
| 327 | 345 | $this->delete( trailingslashit($file) . $delete_file['name'], $recursive, $delete_file['type'] ); |
| 346 | + } |
|
| 328 | 347 | return @ftp_rmdir($this->link, $file); |
| 329 | 348 | } |
| 330 | 349 | |
@@ -441,11 +460,13 @@ discard block |
||
| 441 | 460 | */ |
| 442 | 461 | public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { |
| 443 | 462 | $path = untrailingslashit($path); |
| 444 | - if ( empty($path) ) |
|
| 445 | - return false; |
|
| 463 | + if ( empty($path) ) { |
|
| 464 | + return false; |
|
| 465 | + } |
|
| 446 | 466 | |
| 447 | - if ( !@ftp_mkdir($this->link, $path) ) |
|
| 448 | - return false; |
|
| 467 | + if ( !@ftp_mkdir($this->link, $path) ) { |
|
| 468 | + return false; |
|
| 469 | + } |
|
| 449 | 470 | $this->chmod($path, $chmod); |
| 450 | 471 | return true; |
| 451 | 472 | } |
@@ -470,20 +491,24 @@ discard block |
||
| 470 | 491 | */ |
| 471 | 492 | public function parselisting($line) { |
| 472 | 493 | static $is_windows = null; |
| 473 | - if ( is_null($is_windows) ) |
|
| 474 | - $is_windows = stripos( ftp_systype($this->link), 'win') !== false; |
|
| 494 | + if ( is_null($is_windows) ) { |
|
| 495 | + $is_windows = stripos( ftp_systype($this->link), 'win') !== false; |
|
| 496 | + } |
|
| 475 | 497 | |
| 476 | 498 | if ( $is_windows && preg_match('/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/', $line, $lucifer) ) { |
| 477 | 499 | $b = array(); |
| 478 | - if ( $lucifer[3] < 70 ) |
|
| 479 | - $lucifer[3] +=2000; |
|
| 480 | - else |
|
| 481 | - $lucifer[3] += 1900; // 4digit year fix |
|
| 500 | + if ( $lucifer[3] < 70 ) { |
|
| 501 | + $lucifer[3] +=2000; |
|
| 502 | + } else { |
|
| 503 | + $lucifer[3] += 1900; |
|
| 504 | + } |
|
| 505 | + // 4digit year fix |
|
| 482 | 506 | $b['isdir'] = ( $lucifer[7] == '<DIR>'); |
| 483 | - if ( $b['isdir'] ) |
|
| 484 | - $b['type'] = 'd'; |
|
| 485 | - else |
|
| 486 | - $b['type'] = 'f'; |
|
| 507 | + if ( $b['isdir'] ) { |
|
| 508 | + $b['type'] = 'd'; |
|
| 509 | + } else { |
|
| 510 | + $b['type'] = 'f'; |
|
| 511 | + } |
|
| 487 | 512 | $b['size'] = $lucifer[7]; |
| 488 | 513 | $b['month'] = $lucifer[1]; |
| 489 | 514 | $b['day'] = $lucifer[2]; |
@@ -496,17 +521,19 @@ discard block |
||
| 496 | 521 | } elseif ( !$is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) { |
| 497 | 522 | //echo $line."\n"; |
| 498 | 523 | $lcount = count($lucifer); |
| 499 | - if ( $lcount < 8 ) |
|
| 500 | - return ''; |
|
| 524 | + if ( $lcount < 8 ) { |
|
| 525 | + return ''; |
|
| 526 | + } |
|
| 501 | 527 | $b = array(); |
| 502 | 528 | $b['isdir'] = $lucifer[0]{0} === 'd'; |
| 503 | 529 | $b['islink'] = $lucifer[0]{0} === 'l'; |
| 504 | - if ( $b['isdir'] ) |
|
| 505 | - $b['type'] = 'd'; |
|
| 506 | - elseif ( $b['islink'] ) |
|
| 507 | - $b['type'] = 'l'; |
|
| 508 | - else |
|
| 509 | - $b['type'] = 'f'; |
|
| 530 | + if ( $b['isdir'] ) { |
|
| 531 | + $b['type'] = 'd'; |
|
| 532 | + } elseif ( $b['islink'] ) { |
|
| 533 | + $b['type'] = 'l'; |
|
| 534 | + } else { |
|
| 535 | + $b['type'] = 'f'; |
|
| 536 | + } |
|
| 510 | 537 | $b['perms'] = $lucifer[0]; |
| 511 | 538 | $b['permsn'] = $this->getnumchmodfromh( $b['perms'] ); |
| 512 | 539 | $b['number'] = $lucifer[1]; |
@@ -560,28 +587,36 @@ discard block |
||
| 560 | 587 | } |
| 561 | 588 | |
| 562 | 589 | $pwd = @ftp_pwd($this->link); |
| 563 | - if ( ! @ftp_chdir($this->link, $path) ) // Cant change to folder = folder doesn't exist |
|
| 590 | + if ( ! @ftp_chdir($this->link, $path) ) { |
|
| 591 | + // Cant change to folder = folder doesn't exist |
|
| 564 | 592 | return false; |
| 593 | + } |
|
| 565 | 594 | $list = @ftp_rawlist($this->link, '-a', false); |
| 566 | 595 | @ftp_chdir($this->link, $pwd); |
| 567 | 596 | |
| 568 | - if ( empty($list) ) // Empty array = non-existent folder (real folder will show . at least) |
|
| 597 | + if ( empty($list) ) { |
|
| 598 | + // Empty array = non-existent folder (real folder will show . at least) |
|
| 569 | 599 | return false; |
| 600 | + } |
|
| 570 | 601 | |
| 571 | 602 | $dirlist = array(); |
| 572 | 603 | foreach ( $list as $k => $v ) { |
| 573 | 604 | $entry = $this->parselisting($v); |
| 574 | - if ( empty($entry) ) |
|
| 575 | - continue; |
|
| 605 | + if ( empty($entry) ) { |
|
| 606 | + continue; |
|
| 607 | + } |
|
| 576 | 608 | |
| 577 | - if ( '.' == $entry['name'] || '..' == $entry['name'] ) |
|
| 578 | - continue; |
|
| 609 | + if ( '.' == $entry['name'] || '..' == $entry['name'] ) { |
|
| 610 | + continue; |
|
| 611 | + } |
|
| 579 | 612 | |
| 580 | - if ( ! $include_hidden && '.' == $entry['name'][0] ) |
|
| 581 | - continue; |
|
| 613 | + if ( ! $include_hidden && '.' == $entry['name'][0] ) { |
|
| 614 | + continue; |
|
| 615 | + } |
|
| 582 | 616 | |
| 583 | - if ( $limit_file && $entry['name'] != $limit_file) |
|
| 584 | - continue; |
|
| 617 | + if ( $limit_file && $entry['name'] != $limit_file) { |
|
| 618 | + continue; |
|
| 619 | + } |
|
| 585 | 620 | |
| 586 | 621 | $dirlist[ $entry['name'] ] = $entry; |
| 587 | 622 | } |
@@ -589,10 +624,11 @@ discard block |
||
| 589 | 624 | $ret = array(); |
| 590 | 625 | foreach ( (array)$dirlist as $struc ) { |
| 591 | 626 | if ( 'd' == $struc['type'] ) { |
| 592 | - if ( $recursive ) |
|
| 593 | - $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive); |
|
| 594 | - else |
|
| 595 | - $struc['files'] = array(); |
|
| 627 | + if ( $recursive ) { |
|
| 628 | + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive); |
|
| 629 | + } else { |
|
| 630 | + $struc['files'] = array(); |
|
| 631 | + } |
|
| 596 | 632 | } |
| 597 | 633 | |
| 598 | 634 | $ret[ $struc['name'] ] = $struc; |
@@ -604,7 +640,8 @@ discard block |
||
| 604 | 640 | * @access public |
| 605 | 641 | */ |
| 606 | 642 | public function __destruct() { |
| 607 | - if ( $this->link ) |
|
| 608 | - ftp_close($this->link); |
|
| 643 | + if ( $this->link ) { |
|
| 644 | + ftp_close($this->link); |
|
| 645 | + } |
|
| 609 | 646 | } |
| 610 | 647 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @type bool $Network Whether the plugin can only be activated network-wide. |
| 66 | 66 | * } |
| 67 | 67 | */ |
| 68 | -function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { |
|
| 68 | +function get_plugin_data($plugin_file, $markup = true, $translate = true) { |
|
| 69 | 69 | |
| 70 | 70 | $default_headers = array( |
| 71 | 71 | 'Name' => 'Plugin Name', |
@@ -81,27 +81,27 @@ discard block |
||
| 81 | 81 | '_sitewide' => 'Site Wide Only', |
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | - $plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' ); |
|
| 84 | + $plugin_data = get_file_data($plugin_file, $default_headers, 'plugin'); |
|
| 85 | 85 | |
| 86 | 86 | // Site Wide Only is the old header for Network |
| 87 | - if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) { |
|
| 87 | + if ( ! $plugin_data['Network'] && $plugin_data['_sitewide']) { |
|
| 88 | 88 | /* translators: 1: Site Wide Only: true, 2: Network: true */ |
| 89 | - _deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The %1$s plugin header is deprecated. Use %2$s instead.' ), '<code>Site Wide Only: true</code>', '<code>Network: true</code>' ) ); |
|
| 89 | + _deprecated_argument(__FUNCTION__, '3.0.0', sprintf(__('The %1$s plugin header is deprecated. Use %2$s instead.'), '<code>Site Wide Only: true</code>', '<code>Network: true</code>')); |
|
| 90 | 90 | $plugin_data['Network'] = $plugin_data['_sitewide']; |
| 91 | 91 | } |
| 92 | - $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) ); |
|
| 93 | - unset( $plugin_data['_sitewide'] ); |
|
| 92 | + $plugin_data['Network'] = ('true' == strtolower($plugin_data['Network'])); |
|
| 93 | + unset($plugin_data['_sitewide']); |
|
| 94 | 94 | |
| 95 | 95 | // If no text domain is defined fall back to the plugin slug. |
| 96 | - if ( ! $plugin_data['TextDomain'] ) { |
|
| 97 | - $plugin_slug = dirname( plugin_basename( $plugin_file ) ); |
|
| 98 | - if ( '.' !== $plugin_slug && false === strpos( $plugin_slug, '/' ) ) { |
|
| 96 | + if ( ! $plugin_data['TextDomain']) { |
|
| 97 | + $plugin_slug = dirname(plugin_basename($plugin_file)); |
|
| 98 | + if ('.' !== $plugin_slug && false === strpos($plugin_slug, '/')) { |
|
| 99 | 99 | $plugin_data['TextDomain'] = $plugin_slug; |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if ( $markup || $translate ) { |
|
| 104 | - $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate ); |
|
| 103 | + if ($markup || $translate) { |
|
| 104 | + $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate); |
|
| 105 | 105 | } else { |
| 106 | 106 | $plugin_data['Title'] = $plugin_data['Name']; |
| 107 | 107 | $plugin_data['AuthorName'] = $plugin_data['Author']; |
@@ -117,66 +117,66 @@ discard block |
||
| 117 | 117 | * @access private |
| 118 | 118 | * @see get_plugin_data() |
| 119 | 119 | */ |
| 120 | -function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup = true, $translate = true ) { |
|
| 120 | +function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup = true, $translate = true) { |
|
| 121 | 121 | |
| 122 | 122 | // Sanitize the plugin filename to a WP_PLUGIN_DIR relative path |
| 123 | - $plugin_file = plugin_basename( $plugin_file ); |
|
| 123 | + $plugin_file = plugin_basename($plugin_file); |
|
| 124 | 124 | |
| 125 | 125 | // Translate fields |
| 126 | - if ( $translate ) { |
|
| 127 | - if ( $textdomain = $plugin_data['TextDomain'] ) { |
|
| 128 | - if ( ! is_textdomain_loaded( $textdomain ) ) { |
|
| 129 | - if ( $plugin_data['DomainPath'] ) { |
|
| 130 | - load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] ); |
|
| 126 | + if ($translate) { |
|
| 127 | + if ($textdomain = $plugin_data['TextDomain']) { |
|
| 128 | + if ( ! is_textdomain_loaded($textdomain)) { |
|
| 129 | + if ($plugin_data['DomainPath']) { |
|
| 130 | + load_plugin_textdomain($textdomain, false, dirname($plugin_file).$plugin_data['DomainPath']); |
|
| 131 | 131 | } else { |
| 132 | - load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) ); |
|
| 132 | + load_plugin_textdomain($textdomain, false, dirname($plugin_file)); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | - } elseif ( 'hello.php' == basename( $plugin_file ) ) { |
|
| 135 | + } elseif ('hello.php' == basename($plugin_file)) { |
|
| 136 | 136 | $textdomain = 'default'; |
| 137 | 137 | } |
| 138 | - if ( $textdomain ) { |
|
| 139 | - foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) |
|
| 140 | - $plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain ); |
|
| 138 | + if ($textdomain) { |
|
| 139 | + foreach (array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version') as $field) |
|
| 140 | + $plugin_data[$field] = translate($plugin_data[$field], $textdomain); |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // Sanitize fields |
| 145 | 145 | $allowed_tags = $allowed_tags_in_links = array( |
| 146 | - 'abbr' => array( 'title' => true ), |
|
| 147 | - 'acronym' => array( 'title' => true ), |
|
| 146 | + 'abbr' => array('title' => true), |
|
| 147 | + 'acronym' => array('title' => true), |
|
| 148 | 148 | 'code' => true, |
| 149 | 149 | 'em' => true, |
| 150 | 150 | 'strong' => true, |
| 151 | 151 | ); |
| 152 | - $allowed_tags['a'] = array( 'href' => true, 'title' => true ); |
|
| 152 | + $allowed_tags['a'] = array('href' => true, 'title' => true); |
|
| 153 | 153 | |
| 154 | 154 | // Name is marked up inside <a> tags. Don't allow these. |
| 155 | 155 | // Author is too, but some plugins have used <a> here (omitting Author URI). |
| 156 | - $plugin_data['Name'] = wp_kses( $plugin_data['Name'], $allowed_tags_in_links ); |
|
| 157 | - $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $allowed_tags ); |
|
| 156 | + $plugin_data['Name'] = wp_kses($plugin_data['Name'], $allowed_tags_in_links); |
|
| 157 | + $plugin_data['Author'] = wp_kses($plugin_data['Author'], $allowed_tags); |
|
| 158 | 158 | |
| 159 | - $plugin_data['Description'] = wp_kses( $plugin_data['Description'], $allowed_tags ); |
|
| 160 | - $plugin_data['Version'] = wp_kses( $plugin_data['Version'], $allowed_tags ); |
|
| 159 | + $plugin_data['Description'] = wp_kses($plugin_data['Description'], $allowed_tags); |
|
| 160 | + $plugin_data['Version'] = wp_kses($plugin_data['Version'], $allowed_tags); |
|
| 161 | 161 | |
| 162 | - $plugin_data['PluginURI'] = esc_url( $plugin_data['PluginURI'] ); |
|
| 163 | - $plugin_data['AuthorURI'] = esc_url( $plugin_data['AuthorURI'] ); |
|
| 162 | + $plugin_data['PluginURI'] = esc_url($plugin_data['PluginURI']); |
|
| 163 | + $plugin_data['AuthorURI'] = esc_url($plugin_data['AuthorURI']); |
|
| 164 | 164 | |
| 165 | 165 | $plugin_data['Title'] = $plugin_data['Name']; |
| 166 | 166 | $plugin_data['AuthorName'] = $plugin_data['Author']; |
| 167 | 167 | |
| 168 | 168 | // Apply markup |
| 169 | - if ( $markup ) { |
|
| 170 | - if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) |
|
| 171 | - $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '">' . $plugin_data['Name'] . '</a>'; |
|
| 169 | + if ($markup) { |
|
| 170 | + if ($plugin_data['PluginURI'] && $plugin_data['Name']) |
|
| 171 | + $plugin_data['Title'] = '<a href="'.$plugin_data['PluginURI'].'">'.$plugin_data['Name'].'</a>'; |
|
| 172 | 172 | |
| 173 | - if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) |
|
| 174 | - $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>'; |
|
| 173 | + if ($plugin_data['AuthorURI'] && $plugin_data['Author']) |
|
| 174 | + $plugin_data['Author'] = '<a href="'.$plugin_data['AuthorURI'].'">'.$plugin_data['Author'].'</a>'; |
|
| 175 | 175 | |
| 176 | - $plugin_data['Description'] = wptexturize( $plugin_data['Description'] ); |
|
| 176 | + $plugin_data['Description'] = wptexturize($plugin_data['Description']); |
|
| 177 | 177 | |
| 178 | - if ( $plugin_data['Author'] ) |
|
| 179 | - $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s.'), $plugin_data['Author'] ) . '</cite>'; |
|
| 178 | + if ($plugin_data['Author']) |
|
| 179 | + $plugin_data['Description'] .= ' <cite>'.sprintf(__('By %s.'), $plugin_data['Author']).'</cite>'; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | return $plugin_data; |
@@ -191,31 +191,31 @@ discard block |
||
| 191 | 191 | * @return array List of files relative to the plugin root. |
| 192 | 192 | */ |
| 193 | 193 | function get_plugin_files($plugin) { |
| 194 | - $plugin_file = WP_PLUGIN_DIR . '/' . $plugin; |
|
| 194 | + $plugin_file = WP_PLUGIN_DIR.'/'.$plugin; |
|
| 195 | 195 | $dir = dirname($plugin_file); |
| 196 | 196 | $plugin_files = array($plugin); |
| 197 | - if ( is_dir($dir) && $dir != WP_PLUGIN_DIR ) { |
|
| 198 | - $plugins_dir = @ opendir( $dir ); |
|
| 199 | - if ( $plugins_dir ) { |
|
| 200 | - while (($file = readdir( $plugins_dir ) ) !== false ) { |
|
| 201 | - if ( substr($file, 0, 1) == '.' ) |
|
| 197 | + if (is_dir($dir) && $dir != WP_PLUGIN_DIR) { |
|
| 198 | + $plugins_dir = @ opendir($dir); |
|
| 199 | + if ($plugins_dir) { |
|
| 200 | + while (($file = readdir($plugins_dir)) !== false) { |
|
| 201 | + if (substr($file, 0, 1) == '.') |
|
| 202 | 202 | continue; |
| 203 | - if ( is_dir( $dir . '/' . $file ) ) { |
|
| 204 | - $plugins_subdir = @ opendir( $dir . '/' . $file ); |
|
| 205 | - if ( $plugins_subdir ) { |
|
| 206 | - while (($subfile = readdir( $plugins_subdir ) ) !== false ) { |
|
| 207 | - if ( substr($subfile, 0, 1) == '.' ) |
|
| 203 | + if (is_dir($dir.'/'.$file)) { |
|
| 204 | + $plugins_subdir = @ opendir($dir.'/'.$file); |
|
| 205 | + if ($plugins_subdir) { |
|
| 206 | + while (($subfile = readdir($plugins_subdir)) !== false) { |
|
| 207 | + if (substr($subfile, 0, 1) == '.') |
|
| 208 | 208 | continue; |
| 209 | 209 | $plugin_files[] = plugin_basename("$dir/$file/$subfile"); |
| 210 | 210 | } |
| 211 | - @closedir( $plugins_subdir ); |
|
| 211 | + @closedir($plugins_subdir); |
|
| 212 | 212 | } |
| 213 | 213 | } else { |
| 214 | - if ( plugin_basename("$dir/$file") != $plugin ) |
|
| 214 | + if (plugin_basename("$dir/$file") != $plugin) |
|
| 215 | 215 | $plugin_files[] = plugin_basename("$dir/$file"); |
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | - @closedir( $plugins_dir ); |
|
| 218 | + @closedir($plugins_dir); |
|
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
@@ -244,61 +244,61 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | function get_plugins($plugin_folder = '') { |
| 246 | 246 | |
| 247 | - if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') ) |
|
| 247 | + if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins')) |
|
| 248 | 248 | $cache_plugins = array(); |
| 249 | 249 | |
| 250 | - if ( isset($cache_plugins[ $plugin_folder ]) ) |
|
| 251 | - return $cache_plugins[ $plugin_folder ]; |
|
| 250 | + if (isset($cache_plugins[$plugin_folder])) |
|
| 251 | + return $cache_plugins[$plugin_folder]; |
|
| 252 | 252 | |
| 253 | - $wp_plugins = array (); |
|
| 253 | + $wp_plugins = array(); |
|
| 254 | 254 | $plugin_root = WP_PLUGIN_DIR; |
| 255 | - if ( !empty($plugin_folder) ) |
|
| 255 | + if ( ! empty($plugin_folder)) |
|
| 256 | 256 | $plugin_root .= $plugin_folder; |
| 257 | 257 | |
| 258 | 258 | // Files in wp-content/plugins directory |
| 259 | - $plugins_dir = @ opendir( $plugin_root); |
|
| 259 | + $plugins_dir = @ opendir($plugin_root); |
|
| 260 | 260 | $plugin_files = array(); |
| 261 | - if ( $plugins_dir ) { |
|
| 262 | - while (($file = readdir( $plugins_dir ) ) !== false ) { |
|
| 263 | - if ( substr($file, 0, 1) == '.' ) |
|
| 261 | + if ($plugins_dir) { |
|
| 262 | + while (($file = readdir($plugins_dir)) !== false) { |
|
| 263 | + if (substr($file, 0, 1) == '.') |
|
| 264 | 264 | continue; |
| 265 | - if ( is_dir( $plugin_root.'/'.$file ) ) { |
|
| 266 | - $plugins_subdir = @ opendir( $plugin_root.'/'.$file ); |
|
| 267 | - if ( $plugins_subdir ) { |
|
| 268 | - while (($subfile = readdir( $plugins_subdir ) ) !== false ) { |
|
| 269 | - if ( substr($subfile, 0, 1) == '.' ) |
|
| 265 | + if (is_dir($plugin_root.'/'.$file)) { |
|
| 266 | + $plugins_subdir = @ opendir($plugin_root.'/'.$file); |
|
| 267 | + if ($plugins_subdir) { |
|
| 268 | + while (($subfile = readdir($plugins_subdir)) !== false) { |
|
| 269 | + if (substr($subfile, 0, 1) == '.') |
|
| 270 | 270 | continue; |
| 271 | - if ( substr($subfile, -4) == '.php' ) |
|
| 271 | + if (substr($subfile, -4) == '.php') |
|
| 272 | 272 | $plugin_files[] = "$file/$subfile"; |
| 273 | 273 | } |
| 274 | - closedir( $plugins_subdir ); |
|
| 274 | + closedir($plugins_subdir); |
|
| 275 | 275 | } |
| 276 | 276 | } else { |
| 277 | - if ( substr($file, -4) == '.php' ) |
|
| 277 | + if (substr($file, -4) == '.php') |
|
| 278 | 278 | $plugin_files[] = $file; |
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | - closedir( $plugins_dir ); |
|
| 281 | + closedir($plugins_dir); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - if ( empty($plugin_files) ) |
|
| 284 | + if (empty($plugin_files)) |
|
| 285 | 285 | return $wp_plugins; |
| 286 | 286 | |
| 287 | - foreach ( $plugin_files as $plugin_file ) { |
|
| 288 | - if ( !is_readable( "$plugin_root/$plugin_file" ) ) |
|
| 287 | + foreach ($plugin_files as $plugin_file) { |
|
| 288 | + if ( ! is_readable("$plugin_root/$plugin_file")) |
|
| 289 | 289 | continue; |
| 290 | 290 | |
| 291 | - $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. |
|
| 291 | + $plugin_data = get_plugin_data("$plugin_root/$plugin_file", false, false); //Do not apply markup/translate as it'll be cached. |
|
| 292 | 292 | |
| 293 | - if ( empty ( $plugin_data['Name'] ) ) |
|
| 293 | + if (empty ($plugin_data['Name'])) |
|
| 294 | 294 | continue; |
| 295 | 295 | |
| 296 | - $wp_plugins[plugin_basename( $plugin_file )] = $plugin_data; |
|
| 296 | + $wp_plugins[plugin_basename($plugin_file)] = $plugin_data; |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - uasort( $wp_plugins, '_sort_uname_callback' ); |
|
| 299 | + uasort($wp_plugins, '_sort_uname_callback'); |
|
| 300 | 300 | |
| 301 | - $cache_plugins[ $plugin_folder ] = $wp_plugins; |
|
| 301 | + $cache_plugins[$plugin_folder] = $wp_plugins; |
|
| 302 | 302 | wp_cache_set('plugins', $cache_plugins, 'plugins'); |
| 303 | 303 | |
| 304 | 304 | return $wp_plugins; |
@@ -317,38 +317,38 @@ discard block |
||
| 317 | 317 | // Files in wp-content/mu-plugins directory |
| 318 | 318 | $plugin_files = array(); |
| 319 | 319 | |
| 320 | - if ( ! is_dir( WPMU_PLUGIN_DIR ) ) |
|
| 320 | + if ( ! is_dir(WPMU_PLUGIN_DIR)) |
|
| 321 | 321 | return $wp_plugins; |
| 322 | - if ( $plugins_dir = @ opendir( WPMU_PLUGIN_DIR ) ) { |
|
| 323 | - while ( ( $file = readdir( $plugins_dir ) ) !== false ) { |
|
| 324 | - if ( substr( $file, -4 ) == '.php' ) |
|
| 322 | + if ($plugins_dir = @ opendir(WPMU_PLUGIN_DIR)) { |
|
| 323 | + while (($file = readdir($plugins_dir)) !== false) { |
|
| 324 | + if (substr($file, -4) == '.php') |
|
| 325 | 325 | $plugin_files[] = $file; |
| 326 | 326 | } |
| 327 | 327 | } else { |
| 328 | 328 | return $wp_plugins; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - @closedir( $plugins_dir ); |
|
| 331 | + @closedir($plugins_dir); |
|
| 332 | 332 | |
| 333 | - if ( empty($plugin_files) ) |
|
| 333 | + if (empty($plugin_files)) |
|
| 334 | 334 | return $wp_plugins; |
| 335 | 335 | |
| 336 | - foreach ( $plugin_files as $plugin_file ) { |
|
| 337 | - if ( !is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) ) |
|
| 336 | + foreach ($plugin_files as $plugin_file) { |
|
| 337 | + if ( ! is_readable(WPMU_PLUGIN_DIR."/$plugin_file")) |
|
| 338 | 338 | continue; |
| 339 | 339 | |
| 340 | - $plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. |
|
| 340 | + $plugin_data = get_plugin_data(WPMU_PLUGIN_DIR."/$plugin_file", false, false); //Do not apply markup/translate as it'll be cached. |
|
| 341 | 341 | |
| 342 | - if ( empty ( $plugin_data['Name'] ) ) |
|
| 342 | + if (empty ($plugin_data['Name'])) |
|
| 343 | 343 | $plugin_data['Name'] = $plugin_file; |
| 344 | 344 | |
| 345 | - $wp_plugins[ $plugin_file ] = $plugin_data; |
|
| 345 | + $wp_plugins[$plugin_file] = $plugin_data; |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php') <= 30 ) // silence is golden |
|
| 349 | - unset( $wp_plugins['index.php'] ); |
|
| 348 | + if (isset($wp_plugins['index.php']) && filesize(WPMU_PLUGIN_DIR.'/index.php') <= 30) // silence is golden |
|
| 349 | + unset($wp_plugins['index.php']); |
|
| 350 | 350 | |
| 351 | - uasort( $wp_plugins, '_sort_uname_callback' ); |
|
| 351 | + uasort($wp_plugins, '_sort_uname_callback'); |
|
| 352 | 352 | |
| 353 | 353 | return $wp_plugins; |
| 354 | 354 | } |
@@ -359,8 +359,8 @@ discard block |
||
| 359 | 359 | * @since 3.1.0 |
| 360 | 360 | * @access private |
| 361 | 361 | */ |
| 362 | -function _sort_uname_callback( $a, $b ) { |
|
| 363 | - return strnatcasecmp( $a['Name'], $b['Name'] ); |
|
| 362 | +function _sort_uname_callback($a, $b) { |
|
| 363 | + return strnatcasecmp($a['Name'], $b['Name']); |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | /** |
@@ -376,30 +376,30 @@ discard block |
||
| 376 | 376 | $_dropins = _get_dropins(); |
| 377 | 377 | |
| 378 | 378 | // These exist in the wp-content directory |
| 379 | - if ( $plugins_dir = @ opendir( WP_CONTENT_DIR ) ) { |
|
| 380 | - while ( ( $file = readdir( $plugins_dir ) ) !== false ) { |
|
| 381 | - if ( isset( $_dropins[ $file ] ) ) |
|
| 379 | + if ($plugins_dir = @ opendir(WP_CONTENT_DIR)) { |
|
| 380 | + while (($file = readdir($plugins_dir)) !== false) { |
|
| 381 | + if (isset($_dropins[$file])) |
|
| 382 | 382 | $plugin_files[] = $file; |
| 383 | 383 | } |
| 384 | 384 | } else { |
| 385 | 385 | return $dropins; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - @closedir( $plugins_dir ); |
|
| 388 | + @closedir($plugins_dir); |
|
| 389 | 389 | |
| 390 | - if ( empty($plugin_files) ) |
|
| 390 | + if (empty($plugin_files)) |
|
| 391 | 391 | return $dropins; |
| 392 | 392 | |
| 393 | - foreach ( $plugin_files as $plugin_file ) { |
|
| 394 | - if ( !is_readable( WP_CONTENT_DIR . "/$plugin_file" ) ) |
|
| 393 | + foreach ($plugin_files as $plugin_file) { |
|
| 394 | + if ( ! is_readable(WP_CONTENT_DIR."/$plugin_file")) |
|
| 395 | 395 | continue; |
| 396 | - $plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. |
|
| 397 | - if ( empty( $plugin_data['Name'] ) ) |
|
| 396 | + $plugin_data = get_plugin_data(WP_CONTENT_DIR."/$plugin_file", false, false); //Do not apply markup/translate as it'll be cached. |
|
| 397 | + if (empty($plugin_data['Name'])) |
|
| 398 | 398 | $plugin_data['Name'] = $plugin_file; |
| 399 | - $dropins[ $plugin_file ] = $plugin_data; |
|
| 399 | + $dropins[$plugin_file] = $plugin_data; |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - uksort( $dropins, 'strnatcasecmp' ); |
|
| 402 | + uksort($dropins, 'strnatcasecmp'); |
|
| 403 | 403 | |
| 404 | 404 | return $dropins; |
| 405 | 405 | } |
@@ -416,19 +416,19 @@ discard block |
||
| 416 | 416 | */ |
| 417 | 417 | function _get_dropins() { |
| 418 | 418 | $dropins = array( |
| 419 | - 'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE |
|
| 420 | - 'db.php' => array( __( 'Custom database class.' ), true ), // auto on load |
|
| 421 | - 'db-error.php' => array( __( 'Custom database error message.' ), true ), // auto on error |
|
| 422 | - 'install.php' => array( __( 'Custom install script.' ), true ), // auto on install |
|
| 423 | - 'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // auto on maintenance |
|
| 424 | - 'object-cache.php' => array( __( 'External object cache.' ), true ), // auto on load |
|
| 419 | + 'advanced-cache.php' => array(__('Advanced caching plugin.'), 'WP_CACHE'), // WP_CACHE |
|
| 420 | + 'db.php' => array(__('Custom database class.'), true), // auto on load |
|
| 421 | + 'db-error.php' => array(__('Custom database error message.'), true), // auto on error |
|
| 422 | + 'install.php' => array(__('Custom install script.'), true), // auto on install |
|
| 423 | + 'maintenance.php' => array(__('Custom maintenance message.'), true), // auto on maintenance |
|
| 424 | + 'object-cache.php' => array(__('External object cache.'), true), // auto on load |
|
| 425 | 425 | ); |
| 426 | 426 | |
| 427 | - if ( is_multisite() ) { |
|
| 428 | - $dropins['sunrise.php' ] = array( __( 'Executed before Multisite is loaded.' ), 'SUNRISE' ); // SUNRISE |
|
| 429 | - $dropins['blog-deleted.php' ] = array( __( 'Custom site deleted message.' ), true ); // auto on deleted blog |
|
| 430 | - $dropins['blog-inactive.php' ] = array( __( 'Custom site inactive message.' ), true ); // auto on inactive blog |
|
| 431 | - $dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // auto on archived or spammed blog |
|
| 427 | + if (is_multisite()) { |
|
| 428 | + $dropins['sunrise.php'] = array(__('Executed before Multisite is loaded.'), 'SUNRISE'); // SUNRISE |
|
| 429 | + $dropins['blog-deleted.php'] = array(__('Custom site deleted message.'), true); // auto on deleted blog |
|
| 430 | + $dropins['blog-inactive.php'] = array(__('Custom site inactive message.'), true); // auto on inactive blog |
|
| 431 | + $dropins['blog-suspended.php'] = array(__('Custom site suspended message.'), true); // auto on archived or spammed blog |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | return $dropins; |
@@ -447,8 +447,8 @@ discard block |
||
| 447 | 447 | * @param string $plugin Base plugin path from plugins directory. |
| 448 | 448 | * @return bool True, if in the active plugins list. False, not in the list. |
| 449 | 449 | */ |
| 450 | -function is_plugin_active( $plugin ) { |
|
| 451 | - return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || is_plugin_active_for_network( $plugin ); |
|
| 450 | +function is_plugin_active($plugin) { |
|
| 451 | + return in_array($plugin, (array) get_option('active_plugins', array())) || is_plugin_active_for_network($plugin); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -462,8 +462,8 @@ discard block |
||
| 462 | 462 | * @param string $plugin Base plugin path from plugins directory. |
| 463 | 463 | * @return bool True if inactive. False if active. |
| 464 | 464 | */ |
| 465 | -function is_plugin_inactive( $plugin ) { |
|
| 466 | - return ! is_plugin_active( $plugin ); |
|
| 465 | +function is_plugin_inactive($plugin) { |
|
| 466 | + return ! is_plugin_active($plugin); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | /** |
@@ -479,12 +479,12 @@ discard block |
||
| 479 | 479 | * @param string $plugin Base plugin path from plugins directory. |
| 480 | 480 | * @return bool True, if active for the network, otherwise false. |
| 481 | 481 | */ |
| 482 | -function is_plugin_active_for_network( $plugin ) { |
|
| 483 | - if ( !is_multisite() ) |
|
| 482 | +function is_plugin_active_for_network($plugin) { |
|
| 483 | + if ( ! is_multisite()) |
|
| 484 | 484 | return false; |
| 485 | 485 | |
| 486 | - $plugins = get_site_option( 'active_sitewide_plugins'); |
|
| 487 | - if ( isset($plugins[$plugin]) ) |
|
| 486 | + $plugins = get_site_option('active_sitewide_plugins'); |
|
| 487 | + if (isset($plugins[$plugin])) |
|
| 488 | 488 | return true; |
| 489 | 489 | |
| 490 | 490 | return false; |
@@ -502,9 +502,9 @@ discard block |
||
| 502 | 502 | * @param string $plugin Plugin to check |
| 503 | 503 | * @return bool True if plugin is network only, false otherwise. |
| 504 | 504 | */ |
| 505 | -function is_network_only_plugin( $plugin ) { |
|
| 506 | - $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
|
| 507 | - if ( $plugin_data ) |
|
| 505 | +function is_network_only_plugin($plugin) { |
|
| 506 | + $plugin_data = get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin); |
|
| 507 | + if ($plugin_data) |
|
| 508 | 508 | return $plugin_data['Network']; |
| 509 | 509 | return false; |
| 510 | 510 | } |
@@ -536,31 +536,31 @@ discard block |
||
| 536 | 536 | * @param bool $silent Optional. Whether to prevent calling activation hooks. Default false. |
| 537 | 537 | * @return WP_Error|null WP_Error on invalid file or null on success. |
| 538 | 538 | */ |
| 539 | -function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) { |
|
| 540 | - $plugin = plugin_basename( trim( $plugin ) ); |
|
| 539 | +function activate_plugin($plugin, $redirect = '', $network_wide = false, $silent = false) { |
|
| 540 | + $plugin = plugin_basename(trim($plugin)); |
|
| 541 | 541 | |
| 542 | - if ( is_multisite() && ( $network_wide || is_network_only_plugin($plugin) ) ) { |
|
| 542 | + if (is_multisite() && ($network_wide || is_network_only_plugin($plugin))) { |
|
| 543 | 543 | $network_wide = true; |
| 544 | - $current = get_site_option( 'active_sitewide_plugins', array() ); |
|
| 544 | + $current = get_site_option('active_sitewide_plugins', array()); |
|
| 545 | 545 | $_GET['networkwide'] = 1; // Back compat for plugins looking for this value. |
| 546 | 546 | } else { |
| 547 | - $current = get_option( 'active_plugins', array() ); |
|
| 547 | + $current = get_option('active_plugins', array()); |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | $valid = validate_plugin($plugin); |
| 551 | - if ( is_wp_error($valid) ) |
|
| 551 | + if (is_wp_error($valid)) |
|
| 552 | 552 | return $valid; |
| 553 | 553 | |
| 554 | - if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current ) ) ) { |
|
| 555 | - if ( !empty($redirect) ) |
|
| 556 | - wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error |
|
| 554 | + if (($network_wide && ! isset($current[$plugin])) || ( ! $network_wide && ! in_array($plugin, $current))) { |
|
| 555 | + if ( ! empty($redirect)) |
|
| 556 | + wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_'.$plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error |
|
| 557 | 557 | ob_start(); |
| 558 | - wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); |
|
| 558 | + wp_register_plugin_realpath(WP_PLUGIN_DIR.'/'.$plugin); |
|
| 559 | 559 | $_wp_plugin_file = $plugin; |
| 560 | - include_once( WP_PLUGIN_DIR . '/' . $plugin ); |
|
| 560 | + include_once(WP_PLUGIN_DIR.'/'.$plugin); |
|
| 561 | 561 | $plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin. |
| 562 | 562 | |
| 563 | - if ( ! $silent ) { |
|
| 563 | + if ( ! $silent) { |
|
| 564 | 564 | /** |
| 565 | 565 | * Fires before a plugin is activated. |
| 566 | 566 | * |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | * @param bool $network_wide Whether to enable the plugin for all sites in the network |
| 574 | 574 | * or just the current site. Multisite only. Default is false. |
| 575 | 575 | */ |
| 576 | - do_action( 'activate_plugin', $plugin, $network_wide ); |
|
| 576 | + do_action('activate_plugin', $plugin, $network_wide); |
|
| 577 | 577 | |
| 578 | 578 | /** |
| 579 | 579 | * Fires as a specific plugin is being activated. |
@@ -588,21 +588,21 @@ discard block |
||
| 588 | 588 | * @param bool $network_wide Whether to enable the plugin for all sites in the network |
| 589 | 589 | * or just the current site. Multisite only. Default is false. |
| 590 | 590 | */ |
| 591 | - do_action( 'activate_' . $plugin, $network_wide ); |
|
| 591 | + do_action('activate_'.$plugin, $network_wide); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - if ( $network_wide ) { |
|
| 595 | - $current = get_site_option( 'active_sitewide_plugins', array() ); |
|
| 594 | + if ($network_wide) { |
|
| 595 | + $current = get_site_option('active_sitewide_plugins', array()); |
|
| 596 | 596 | $current[$plugin] = time(); |
| 597 | - update_site_option( 'active_sitewide_plugins', $current ); |
|
| 597 | + update_site_option('active_sitewide_plugins', $current); |
|
| 598 | 598 | } else { |
| 599 | - $current = get_option( 'active_plugins', array() ); |
|
| 599 | + $current = get_option('active_plugins', array()); |
|
| 600 | 600 | $current[] = $plugin; |
| 601 | 601 | sort($current); |
| 602 | 602 | update_option('active_plugins', $current); |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | - if ( ! $silent ) { |
|
| 605 | + if ( ! $silent) { |
|
| 606 | 606 | /** |
| 607 | 607 | * Fires after a plugin has been activated. |
| 608 | 608 | * |
@@ -615,10 +615,10 @@ discard block |
||
| 615 | 615 | * @param bool $network_wide Whether to enable the plugin for all sites in the network |
| 616 | 616 | * or just the current site. Multisite only. Default is false. |
| 617 | 617 | */ |
| 618 | - do_action( 'activated_plugin', $plugin, $network_wide ); |
|
| 618 | + do_action('activated_plugin', $plugin, $network_wide); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | - if ( ob_get_length() > 0 ) { |
|
| 621 | + if (ob_get_length() > 0) { |
|
| 622 | 622 | $output = ob_get_clean(); |
| 623 | 623 | return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output); |
| 624 | 624 | } |
@@ -641,20 +641,20 @@ discard block |
||
| 641 | 641 | * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network. |
| 642 | 642 | * A value of null (the default) will deactivate plugins for both the site and the network. |
| 643 | 643 | */ |
| 644 | -function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) { |
|
| 645 | - if ( is_multisite() ) |
|
| 646 | - $network_current = get_site_option( 'active_sitewide_plugins', array() ); |
|
| 647 | - $current = get_option( 'active_plugins', array() ); |
|
| 644 | +function deactivate_plugins($plugins, $silent = false, $network_wide = null) { |
|
| 645 | + if (is_multisite()) |
|
| 646 | + $network_current = get_site_option('active_sitewide_plugins', array()); |
|
| 647 | + $current = get_option('active_plugins', array()); |
|
| 648 | 648 | $do_blog = $do_network = false; |
| 649 | 649 | |
| 650 | - foreach ( (array) $plugins as $plugin ) { |
|
| 651 | - $plugin = plugin_basename( trim( $plugin ) ); |
|
| 652 | - if ( ! is_plugin_active($plugin) ) |
|
| 650 | + foreach ((array) $plugins as $plugin) { |
|
| 651 | + $plugin = plugin_basename(trim($plugin)); |
|
| 652 | + if ( ! is_plugin_active($plugin)) |
|
| 653 | 653 | continue; |
| 654 | 654 | |
| 655 | - $network_deactivating = false !== $network_wide && is_plugin_active_for_network( $plugin ); |
|
| 655 | + $network_deactivating = false !== $network_wide && is_plugin_active_for_network($plugin); |
|
| 656 | 656 | |
| 657 | - if ( ! $silent ) { |
|
| 657 | + if ( ! $silent) { |
|
| 658 | 658 | /** |
| 659 | 659 | * Fires before a plugin is deactivated. |
| 660 | 660 | * |
@@ -667,27 +667,27 @@ discard block |
||
| 667 | 667 | * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network |
| 668 | 668 | * or just the current site. Multisite only. Default is false. |
| 669 | 669 | */ |
| 670 | - do_action( 'deactivate_plugin', $plugin, $network_deactivating ); |
|
| 670 | + do_action('deactivate_plugin', $plugin, $network_deactivating); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - if ( false !== $network_wide ) { |
|
| 674 | - if ( is_plugin_active_for_network( $plugin ) ) { |
|
| 673 | + if (false !== $network_wide) { |
|
| 674 | + if (is_plugin_active_for_network($plugin)) { |
|
| 675 | 675 | $do_network = true; |
| 676 | - unset( $network_current[ $plugin ] ); |
|
| 677 | - } elseif ( $network_wide ) { |
|
| 676 | + unset($network_current[$plugin]); |
|
| 677 | + } elseif ($network_wide) { |
|
| 678 | 678 | continue; |
| 679 | 679 | } |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - if ( true !== $network_wide ) { |
|
| 683 | - $key = array_search( $plugin, $current ); |
|
| 684 | - if ( false !== $key ) { |
|
| 682 | + if (true !== $network_wide) { |
|
| 683 | + $key = array_search($plugin, $current); |
|
| 684 | + if (false !== $key) { |
|
| 685 | 685 | $do_blog = true; |
| 686 | - unset( $current[ $key ] ); |
|
| 686 | + unset($current[$key]); |
|
| 687 | 687 | } |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | - if ( ! $silent ) { |
|
| 690 | + if ( ! $silent) { |
|
| 691 | 691 | /** |
| 692 | 692 | * Fires as a specific plugin is being deactivated. |
| 693 | 693 | * |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network |
| 702 | 702 | * or just the current site. Multisite only. Default is false. |
| 703 | 703 | */ |
| 704 | - do_action( 'deactivate_' . $plugin, $network_deactivating ); |
|
| 704 | + do_action('deactivate_'.$plugin, $network_deactivating); |
|
| 705 | 705 | |
| 706 | 706 | /** |
| 707 | 707 | * Fires after a plugin is deactivated. |
@@ -715,14 +715,14 @@ discard block |
||
| 715 | 715 | * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network |
| 716 | 716 | * or just the current site. Multisite only. Default false. |
| 717 | 717 | */ |
| 718 | - do_action( 'deactivated_plugin', $plugin, $network_deactivating ); |
|
| 718 | + do_action('deactivated_plugin', $plugin, $network_deactivating); |
|
| 719 | 719 | } |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - if ( $do_blog ) |
|
| 722 | + if ($do_blog) |
|
| 723 | 723 | update_option('active_plugins', $current); |
| 724 | - if ( $do_network ) |
|
| 725 | - update_site_option( 'active_sitewide_plugins', $network_current ); |
|
| 724 | + if ($do_network) |
|
| 725 | + update_site_option('active_sitewide_plugins', $network_current); |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | /** |
@@ -741,20 +741,20 @@ discard block |
||
| 741 | 741 | * @param bool $silent Prevent calling activation hooks. Default is false. |
| 742 | 742 | * @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation. |
| 743 | 743 | */ |
| 744 | -function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) { |
|
| 745 | - if ( !is_array($plugins) ) |
|
| 744 | +function activate_plugins($plugins, $redirect = '', $network_wide = false, $silent = false) { |
|
| 745 | + if ( ! is_array($plugins)) |
|
| 746 | 746 | $plugins = array($plugins); |
| 747 | 747 | |
| 748 | 748 | $errors = array(); |
| 749 | - foreach ( $plugins as $plugin ) { |
|
| 750 | - if ( !empty($redirect) ) |
|
| 749 | + foreach ($plugins as $plugin) { |
|
| 750 | + if ( ! empty($redirect)) |
|
| 751 | 751 | $redirect = add_query_arg('plugin', $plugin, $redirect); |
| 752 | 752 | $result = activate_plugin($plugin, $redirect, $network_wide, $silent); |
| 753 | - if ( is_wp_error($result) ) |
|
| 753 | + if (is_wp_error($result)) |
|
| 754 | 754 | $errors[$plugin] = $result; |
| 755 | 755 | } |
| 756 | 756 | |
| 757 | - if ( !empty($errors) ) |
|
| 757 | + if ( ! empty($errors)) |
|
| 758 | 758 | return new WP_Error('plugins_invalid', __('One of the plugins is invalid.'), $errors); |
| 759 | 759 | |
| 760 | 760 | return true; |
@@ -772,67 +772,67 @@ discard block |
||
| 772 | 772 | * @return bool|null|WP_Error True on success, false is $plugins is empty, WP_Error on failure. |
| 773 | 773 | * Null if filesystem credentials are required to proceed. |
| 774 | 774 | */ |
| 775 | -function delete_plugins( $plugins, $deprecated = '' ) { |
|
| 775 | +function delete_plugins($plugins, $deprecated = '') { |
|
| 776 | 776 | global $wp_filesystem; |
| 777 | 777 | |
| 778 | - if ( empty($plugins) ) |
|
| 778 | + if (empty($plugins)) |
|
| 779 | 779 | return false; |
| 780 | 780 | |
| 781 | 781 | $checked = array(); |
| 782 | - foreach ( $plugins as $plugin ) |
|
| 783 | - $checked[] = 'checked[]=' . $plugin; |
|
| 782 | + foreach ($plugins as $plugin) |
|
| 783 | + $checked[] = 'checked[]='.$plugin; |
|
| 784 | 784 | |
| 785 | - $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-plugins'); |
|
| 785 | + $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&'.implode('&', $checked), 'bulk-plugins'); |
|
| 786 | 786 | |
| 787 | 787 | ob_start(); |
| 788 | - $credentials = request_filesystem_credentials( $url ); |
|
| 788 | + $credentials = request_filesystem_credentials($url); |
|
| 789 | 789 | $data = ob_get_clean(); |
| 790 | 790 | |
| 791 | - if ( false === $credentials ) { |
|
| 792 | - if ( ! empty($data) ){ |
|
| 793 | - include_once( ABSPATH . 'wp-admin/admin-header.php'); |
|
| 791 | + if (false === $credentials) { |
|
| 792 | + if ( ! empty($data)) { |
|
| 793 | + include_once(ABSPATH.'wp-admin/admin-header.php'); |
|
| 794 | 794 | echo $data; |
| 795 | - include( ABSPATH . 'wp-admin/admin-footer.php'); |
|
| 795 | + include(ABSPATH.'wp-admin/admin-footer.php'); |
|
| 796 | 796 | exit; |
| 797 | 797 | } |
| 798 | 798 | return; |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | - if ( ! WP_Filesystem( $credentials ) ) { |
|
| 801 | + if ( ! WP_Filesystem($credentials)) { |
|
| 802 | 802 | ob_start(); |
| 803 | - request_filesystem_credentials( $url, '', true ); // Failed to connect, Error and request again. |
|
| 803 | + request_filesystem_credentials($url, '', true); // Failed to connect, Error and request again. |
|
| 804 | 804 | $data = ob_get_clean(); |
| 805 | 805 | |
| 806 | - if ( ! empty($data) ){ |
|
| 807 | - include_once( ABSPATH . 'wp-admin/admin-header.php'); |
|
| 806 | + if ( ! empty($data)) { |
|
| 807 | + include_once(ABSPATH.'wp-admin/admin-header.php'); |
|
| 808 | 808 | echo $data; |
| 809 | - include( ABSPATH . 'wp-admin/admin-footer.php'); |
|
| 809 | + include(ABSPATH.'wp-admin/admin-footer.php'); |
|
| 810 | 810 | exit; |
| 811 | 811 | } |
| 812 | 812 | return; |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | - if ( ! is_object($wp_filesystem) ) |
|
| 815 | + if ( ! is_object($wp_filesystem)) |
|
| 816 | 816 | return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
| 817 | 817 | |
| 818 | - if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) |
|
| 818 | + if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) |
|
| 819 | 819 | return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors); |
| 820 | 820 | |
| 821 | 821 | // Get the base plugin folder. |
| 822 | 822 | $plugins_dir = $wp_filesystem->wp_plugins_dir(); |
| 823 | - if ( empty( $plugins_dir ) ) { |
|
| 824 | - return new WP_Error( 'fs_no_plugins_dir', __( 'Unable to locate WordPress plugin directory.' ) ); |
|
| 823 | + if (empty($plugins_dir)) { |
|
| 824 | + return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress plugin directory.')); |
|
| 825 | 825 | } |
| 826 | 826 | |
| 827 | - $plugins_dir = trailingslashit( $plugins_dir ); |
|
| 827 | + $plugins_dir = trailingslashit($plugins_dir); |
|
| 828 | 828 | |
| 829 | - $plugin_translations = wp_get_installed_translations( 'plugins' ); |
|
| 829 | + $plugin_translations = wp_get_installed_translations('plugins'); |
|
| 830 | 830 | |
| 831 | 831 | $errors = array(); |
| 832 | 832 | |
| 833 | - foreach ( $plugins as $plugin_file ) { |
|
| 833 | + foreach ($plugins as $plugin_file) { |
|
| 834 | 834 | // Run Uninstall hook. |
| 835 | - if ( is_uninstallable_plugin( $plugin_file ) ) { |
|
| 835 | + if (is_uninstallable_plugin($plugin_file)) { |
|
| 836 | 836 | uninstall_plugin($plugin_file); |
| 837 | 837 | } |
| 838 | 838 | |
@@ -843,15 +843,15 @@ discard block |
||
| 843 | 843 | * |
| 844 | 844 | * @param string $plugin_file Plugin file name. |
| 845 | 845 | */ |
| 846 | - do_action( 'delete_plugin', $plugin_file ); |
|
| 846 | + do_action('delete_plugin', $plugin_file); |
|
| 847 | 847 | |
| 848 | - $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) ); |
|
| 848 | + $this_plugin_dir = trailingslashit(dirname($plugins_dir.$plugin_file)); |
|
| 849 | 849 | |
| 850 | 850 | // If plugin is in its own directory, recursively delete the directory. |
| 851 | - if ( strpos( $plugin_file, '/' ) && $this_plugin_dir != $plugins_dir ) { //base check on if plugin includes directory separator AND that it's not the root plugin folder |
|
| 852 | - $deleted = $wp_filesystem->delete( $this_plugin_dir, true ); |
|
| 851 | + if (strpos($plugin_file, '/') && $this_plugin_dir != $plugins_dir) { //base check on if plugin includes directory separator AND that it's not the root plugin folder |
|
| 852 | + $deleted = $wp_filesystem->delete($this_plugin_dir, true); |
|
| 853 | 853 | } else { |
| 854 | - $deleted = $wp_filesystem->delete( $plugins_dir . $plugin_file ); |
|
| 854 | + $deleted = $wp_filesystem->delete($plugins_dir.$plugin_file); |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | /** |
@@ -862,39 +862,39 @@ discard block |
||
| 862 | 862 | * @param string $plugin_file Plugin file name. |
| 863 | 863 | * @param bool $deleted Whether the plugin deletion was successful. |
| 864 | 864 | */ |
| 865 | - do_action( 'deleted_plugin', $plugin_file, $deleted ); |
|
| 865 | + do_action('deleted_plugin', $plugin_file, $deleted); |
|
| 866 | 866 | |
| 867 | - if ( ! $deleted ) { |
|
| 867 | + if ( ! $deleted) { |
|
| 868 | 868 | $errors[] = $plugin_file; |
| 869 | 869 | continue; |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | // Remove language files, silently. |
| 873 | - $plugin_slug = dirname( $plugin_file ); |
|
| 874 | - if ( '.' !== $plugin_slug && ! empty( $plugin_translations[ $plugin_slug ] ) ) { |
|
| 875 | - $translations = $plugin_translations[ $plugin_slug ]; |
|
| 873 | + $plugin_slug = dirname($plugin_file); |
|
| 874 | + if ('.' !== $plugin_slug && ! empty($plugin_translations[$plugin_slug])) { |
|
| 875 | + $translations = $plugin_translations[$plugin_slug]; |
|
| 876 | 876 | |
| 877 | - foreach ( $translations as $translation => $data ) { |
|
| 878 | - $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.po' ); |
|
| 879 | - $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.mo' ); |
|
| 877 | + foreach ($translations as $translation => $data) { |
|
| 878 | + $wp_filesystem->delete(WP_LANG_DIR.'/plugins/'.$plugin_slug.'-'.$translation.'.po'); |
|
| 879 | + $wp_filesystem->delete(WP_LANG_DIR.'/plugins/'.$plugin_slug.'-'.$translation.'.mo'); |
|
| 880 | 880 | } |
| 881 | 881 | } |
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | // Remove deleted plugins from the plugin updates list. |
| 885 | - if ( $current = get_site_transient('update_plugins') ) { |
|
| 885 | + if ($current = get_site_transient('update_plugins')) { |
|
| 886 | 886 | // Don't remove the plugins that weren't deleted. |
| 887 | - $deleted = array_diff( $plugins, $errors ); |
|
| 887 | + $deleted = array_diff($plugins, $errors); |
|
| 888 | 888 | |
| 889 | - foreach ( $deleted as $plugin_file ) { |
|
| 890 | - unset( $current->response[ $plugin_file ] ); |
|
| 889 | + foreach ($deleted as $plugin_file) { |
|
| 890 | + unset($current->response[$plugin_file]); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | - set_site_transient( 'update_plugins', $current ); |
|
| 893 | + set_site_transient('update_plugins', $current); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | - if ( ! empty($errors) ) |
|
| 897 | - return new WP_Error('could_not_remove_plugin', sprintf(__('Could not fully remove the plugin(s) %s.'), implode(', ', $errors)) ); |
|
| 896 | + if ( ! empty($errors)) |
|
| 897 | + return new WP_Error('could_not_remove_plugin', sprintf(__('Could not fully remove the plugin(s) %s.'), implode(', ', $errors))); |
|
| 898 | 898 | |
| 899 | 899 | return true; |
| 900 | 900 | } |
@@ -909,29 +909,29 @@ discard block |
||
| 909 | 909 | * @return array invalid plugins, plugin as key, error as value |
| 910 | 910 | */ |
| 911 | 911 | function validate_active_plugins() { |
| 912 | - $plugins = get_option( 'active_plugins', array() ); |
|
| 912 | + $plugins = get_option('active_plugins', array()); |
|
| 913 | 913 | // Validate vartype: array. |
| 914 | - if ( ! is_array( $plugins ) ) { |
|
| 915 | - update_option( 'active_plugins', array() ); |
|
| 914 | + if ( ! is_array($plugins)) { |
|
| 915 | + update_option('active_plugins', array()); |
|
| 916 | 916 | $plugins = array(); |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | - if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) { |
|
| 920 | - $network_plugins = (array) get_site_option( 'active_sitewide_plugins', array() ); |
|
| 921 | - $plugins = array_merge( $plugins, array_keys( $network_plugins ) ); |
|
| 919 | + if (is_multisite() && current_user_can('manage_network_plugins')) { |
|
| 920 | + $network_plugins = (array) get_site_option('active_sitewide_plugins', array()); |
|
| 921 | + $plugins = array_merge($plugins, array_keys($network_plugins)); |
|
| 922 | 922 | } |
| 923 | 923 | |
| 924 | - if ( empty( $plugins ) ) |
|
| 924 | + if (empty($plugins)) |
|
| 925 | 925 | return array(); |
| 926 | 926 | |
| 927 | 927 | $invalid = array(); |
| 928 | 928 | |
| 929 | 929 | // Invalid plugins get deactivated. |
| 930 | - foreach ( $plugins as $plugin ) { |
|
| 931 | - $result = validate_plugin( $plugin ); |
|
| 932 | - if ( is_wp_error( $result ) ) { |
|
| 930 | + foreach ($plugins as $plugin) { |
|
| 931 | + $result = validate_plugin($plugin); |
|
| 932 | + if (is_wp_error($result)) { |
|
| 933 | 933 | $invalid[$plugin] = $result; |
| 934 | - deactivate_plugins( $plugin, true ); |
|
| 934 | + deactivate_plugins($plugin, true); |
|
| 935 | 935 | } |
| 936 | 936 | } |
| 937 | 937 | return $invalid; |
@@ -948,13 +948,13 @@ discard block |
||
| 948 | 948 | * @return WP_Error|int 0 on success, WP_Error on failure. |
| 949 | 949 | */ |
| 950 | 950 | function validate_plugin($plugin) { |
| 951 | - if ( validate_file($plugin) ) |
|
| 951 | + if (validate_file($plugin)) |
|
| 952 | 952 | return new WP_Error('plugin_invalid', __('Invalid plugin path.')); |
| 953 | - if ( ! file_exists(WP_PLUGIN_DIR . '/' . $plugin) ) |
|
| 953 | + if ( ! file_exists(WP_PLUGIN_DIR.'/'.$plugin)) |
|
| 954 | 954 | return new WP_Error('plugin_not_found', __('Plugin file does not exist.')); |
| 955 | 955 | |
| 956 | 956 | $installed_plugins = get_plugins(); |
| 957 | - if ( ! isset($installed_plugins[$plugin]) ) |
|
| 957 | + if ( ! isset($installed_plugins[$plugin])) |
|
| 958 | 958 | return new WP_Error('no_plugin_header', __('The plugin does not have a valid header.')); |
| 959 | 959 | return 0; |
| 960 | 960 | } |
@@ -971,7 +971,7 @@ discard block |
||
| 971 | 971 | $file = plugin_basename($plugin); |
| 972 | 972 | |
| 973 | 973 | $uninstallable_plugins = (array) get_option('uninstall_plugins'); |
| 974 | - if ( isset( $uninstallable_plugins[$file] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) |
|
| 974 | + if (isset($uninstallable_plugins[$file]) || file_exists(WP_PLUGIN_DIR.'/'.dirname($file).'/uninstall.php')) |
|
| 975 | 975 | return true; |
| 976 | 976 | |
| 977 | 977 | return false; |
@@ -1000,32 +1000,32 @@ discard block |
||
| 1000 | 1000 | * @param string $plugin Relative plugin path from plugin directory. |
| 1001 | 1001 | * @param array $uninstallable_plugins Uninstallable plugins. |
| 1002 | 1002 | */ |
| 1003 | - do_action( 'pre_uninstall_plugin', $plugin, $uninstallable_plugins ); |
|
| 1003 | + do_action('pre_uninstall_plugin', $plugin, $uninstallable_plugins); |
|
| 1004 | 1004 | |
| 1005 | - if ( file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) { |
|
| 1006 | - if ( isset( $uninstallable_plugins[$file] ) ) { |
|
| 1005 | + if (file_exists(WP_PLUGIN_DIR.'/'.dirname($file).'/uninstall.php')) { |
|
| 1006 | + if (isset($uninstallable_plugins[$file])) { |
|
| 1007 | 1007 | unset($uninstallable_plugins[$file]); |
| 1008 | 1008 | update_option('uninstall_plugins', $uninstallable_plugins); |
| 1009 | 1009 | } |
| 1010 | 1010 | unset($uninstallable_plugins); |
| 1011 | 1011 | |
| 1012 | 1012 | define('WP_UNINSTALL_PLUGIN', $file); |
| 1013 | - wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file ); |
|
| 1014 | - include( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ); |
|
| 1013 | + wp_register_plugin_realpath(WP_PLUGIN_DIR.'/'.$file); |
|
| 1014 | + include(WP_PLUGIN_DIR.'/'.dirname($file).'/uninstall.php'); |
|
| 1015 | 1015 | |
| 1016 | 1016 | return true; |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | - if ( isset( $uninstallable_plugins[$file] ) ) { |
|
| 1019 | + if (isset($uninstallable_plugins[$file])) { |
|
| 1020 | 1020 | $callable = $uninstallable_plugins[$file]; |
| 1021 | 1021 | unset($uninstallable_plugins[$file]); |
| 1022 | 1022 | update_option('uninstall_plugins', $uninstallable_plugins); |
| 1023 | 1023 | unset($uninstallable_plugins); |
| 1024 | 1024 | |
| 1025 | - wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file ); |
|
| 1026 | - include( WP_PLUGIN_DIR . '/' . $file ); |
|
| 1025 | + wp_register_plugin_realpath(WP_PLUGIN_DIR.'/'.$file); |
|
| 1026 | + include(WP_PLUGIN_DIR.'/'.$file); |
|
| 1027 | 1027 | |
| 1028 | - add_action( 'uninstall_' . $file, $callable ); |
|
| 1028 | + add_action('uninstall_'.$file, $callable); |
|
| 1029 | 1029 | |
| 1030 | 1030 | /** |
| 1031 | 1031 | * Fires in uninstall_plugin() once the plugin has been uninstalled. |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | * |
| 1036 | 1036 | * @since 2.7.0 |
| 1037 | 1037 | */ |
| 1038 | - do_action( 'uninstall_' . $file ); |
|
| 1038 | + do_action('uninstall_'.$file); |
|
| 1039 | 1039 | } |
| 1040 | 1040 | } |
| 1041 | 1041 | |
@@ -1071,35 +1071,35 @@ discard block |
||
| 1071 | 1071 | * @param int $position The position in the menu order this one should appear. |
| 1072 | 1072 | * @return string The resulting page's hook_suffix. |
| 1073 | 1073 | */ |
| 1074 | -function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) { |
|
| 1074 | +function add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null) { |
|
| 1075 | 1075 | global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages; |
| 1076 | 1076 | |
| 1077 | - $menu_slug = plugin_basename( $menu_slug ); |
|
| 1077 | + $menu_slug = plugin_basename($menu_slug); |
|
| 1078 | 1078 | |
| 1079 | - $admin_page_hooks[$menu_slug] = sanitize_title( $menu_title ); |
|
| 1079 | + $admin_page_hooks[$menu_slug] = sanitize_title($menu_title); |
|
| 1080 | 1080 | |
| 1081 | - $hookname = get_plugin_page_hookname( $menu_slug, '' ); |
|
| 1081 | + $hookname = get_plugin_page_hookname($menu_slug, ''); |
|
| 1082 | 1082 | |
| 1083 | - if ( !empty( $function ) && !empty( $hookname ) && current_user_can( $capability ) ) |
|
| 1084 | - add_action( $hookname, $function ); |
|
| 1083 | + if ( ! empty($function) && ! empty($hookname) && current_user_can($capability)) |
|
| 1084 | + add_action($hookname, $function); |
|
| 1085 | 1085 | |
| 1086 | - if ( empty($icon_url) ) { |
|
| 1086 | + if (empty($icon_url)) { |
|
| 1087 | 1087 | $icon_url = 'dashicons-admin-generic'; |
| 1088 | 1088 | $icon_class = 'menu-icon-generic '; |
| 1089 | 1089 | } else { |
| 1090 | - $icon_url = set_url_scheme( $icon_url ); |
|
| 1090 | + $icon_url = set_url_scheme($icon_url); |
|
| 1091 | 1091 | $icon_class = ''; |
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | - $new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url ); |
|
| 1094 | + $new_menu = array($menu_title, $capability, $menu_slug, $page_title, 'menu-top '.$icon_class.$hookname, $hookname, $icon_url); |
|
| 1095 | 1095 | |
| 1096 | - if ( null === $position ) { |
|
| 1096 | + if (null === $position) { |
|
| 1097 | 1097 | $menu[] = $new_menu; |
| 1098 | - } elseif ( isset( $menu[ "$position" ] ) ) { |
|
| 1099 | - $position = $position + substr( base_convert( md5( $menu_slug . $menu_title ), 16, 10 ) , -5 ) * 0.00001; |
|
| 1100 | - $menu[ "$position" ] = $new_menu; |
|
| 1098 | + } elseif (isset($menu["$position"])) { |
|
| 1099 | + $position = $position + substr(base_convert(md5($menu_slug.$menu_title), 16, 10), -5) * 0.00001; |
|
| 1100 | + $menu["$position"] = $new_menu; |
|
| 1101 | 1101 | } else { |
| 1102 | - $menu[ $position ] = $new_menu; |
|
| 1102 | + $menu[$position] = $new_menu; |
|
| 1103 | 1103 | } |
| 1104 | 1104 | |
| 1105 | 1105 | $_registered_pages[$hookname] = true; |
@@ -1134,17 +1134,17 @@ discard block |
||
| 1134 | 1134 | * @param callable $function The function to be called to output the content for this page. |
| 1135 | 1135 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1136 | 1136 | */ |
| 1137 | -function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1137 | +function add_submenu_page($parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1138 | 1138 | global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv, |
| 1139 | 1139 | $_registered_pages, $_parent_pages; |
| 1140 | 1140 | |
| 1141 | - $menu_slug = plugin_basename( $menu_slug ); |
|
| 1142 | - $parent_slug = plugin_basename( $parent_slug); |
|
| 1141 | + $menu_slug = plugin_basename($menu_slug); |
|
| 1142 | + $parent_slug = plugin_basename($parent_slug); |
|
| 1143 | 1143 | |
| 1144 | - if ( isset( $_wp_real_parent_file[$parent_slug] ) ) |
|
| 1144 | + if (isset($_wp_real_parent_file[$parent_slug])) |
|
| 1145 | 1145 | $parent_slug = $_wp_real_parent_file[$parent_slug]; |
| 1146 | 1146 | |
| 1147 | - if ( !current_user_can( $capability ) ) { |
|
| 1147 | + if ( ! current_user_can($capability)) { |
|
| 1148 | 1148 | $_wp_submenu_nopriv[$parent_slug][$menu_slug] = true; |
| 1149 | 1149 | return false; |
| 1150 | 1150 | } |
@@ -1155,18 +1155,18 @@ discard block |
||
| 1155 | 1155 | * parent file someone is trying to link back to the parent manually. In |
| 1156 | 1156 | * this case, don't automatically add a link back to avoid duplication. |
| 1157 | 1157 | */ |
| 1158 | - if (!isset( $submenu[$parent_slug] ) && $menu_slug != $parent_slug ) { |
|
| 1159 | - foreach ( (array)$menu as $parent_menu ) { |
|
| 1160 | - if ( $parent_menu[2] == $parent_slug && current_user_can( $parent_menu[1] ) ) |
|
| 1161 | - $submenu[$parent_slug][] = array_slice( $parent_menu, 0, 4 ); |
|
| 1158 | + if ( ! isset($submenu[$parent_slug]) && $menu_slug != $parent_slug) { |
|
| 1159 | + foreach ((array) $menu as $parent_menu) { |
|
| 1160 | + if ($parent_menu[2] == $parent_slug && current_user_can($parent_menu[1])) |
|
| 1161 | + $submenu[$parent_slug][] = array_slice($parent_menu, 0, 4); |
|
| 1162 | 1162 | } |
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | - $submenu[$parent_slug][] = array ( $menu_title, $capability, $menu_slug, $page_title ); |
|
| 1165 | + $submenu[$parent_slug][] = array($menu_title, $capability, $menu_slug, $page_title); |
|
| 1166 | 1166 | |
| 1167 | - $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug); |
|
| 1168 | - if (!empty ( $function ) && !empty ( $hookname )) |
|
| 1169 | - add_action( $hookname, $function ); |
|
| 1167 | + $hookname = get_plugin_page_hookname($menu_slug, $parent_slug); |
|
| 1168 | + if ( ! empty ($function) && ! empty ($hookname)) |
|
| 1169 | + add_action($hookname, $function); |
|
| 1170 | 1170 | |
| 1171 | 1171 | $_registered_pages[$hookname] = true; |
| 1172 | 1172 | |
@@ -1174,8 +1174,8 @@ discard block |
||
| 1174 | 1174 | * Backward-compatibility for plugins using add_management page. |
| 1175 | 1175 | * See wp-admin/admin.php for redirect from edit.php to tools.php |
| 1176 | 1176 | */ |
| 1177 | - if ( 'tools.php' == $parent_slug ) |
|
| 1178 | - $_registered_pages[get_plugin_page_hookname( $menu_slug, 'edit.php')] = true; |
|
| 1177 | + if ('tools.php' == $parent_slug) |
|
| 1178 | + $_registered_pages[get_plugin_page_hookname($menu_slug, 'edit.php')] = true; |
|
| 1179 | 1179 | |
| 1180 | 1180 | // No parent as top level. |
| 1181 | 1181 | $_parent_pages[$menu_slug] = $parent_slug; |
@@ -1199,8 +1199,8 @@ discard block |
||
| 1199 | 1199 | * @param callable $function The function to be called to output the content for this page. |
| 1200 | 1200 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1201 | 1201 | */ |
| 1202 | -function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1203 | - return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1202 | +function add_management_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1203 | + return add_submenu_page('tools.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | 1206 | /** |
@@ -1219,8 +1219,8 @@ discard block |
||
| 1219 | 1219 | * @param callable $function The function to be called to output the content for this page. |
| 1220 | 1220 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1221 | 1221 | */ |
| 1222 | -function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1223 | - return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1222 | +function add_options_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1223 | + return add_submenu_page('options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | 1226 | /** |
@@ -1239,8 +1239,8 @@ discard block |
||
| 1239 | 1239 | * @param callable $function The function to be called to output the content for this page. |
| 1240 | 1240 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1241 | 1241 | */ |
| 1242 | -function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1243 | - return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1242 | +function add_theme_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1243 | + return add_submenu_page('themes.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | 1246 | /** |
@@ -1259,8 +1259,8 @@ discard block |
||
| 1259 | 1259 | * @param callable $function The function to be called to output the content for this page. |
| 1260 | 1260 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1261 | 1261 | */ |
| 1262 | -function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1263 | - return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1262 | +function add_plugins_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1263 | + return add_submenu_page('plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | /** |
@@ -1279,12 +1279,12 @@ discard block |
||
| 1279 | 1279 | * @param callable $function The function to be called to output the content for this page. |
| 1280 | 1280 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1281 | 1281 | */ |
| 1282 | -function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1283 | - if ( current_user_can('edit_users') ) |
|
| 1282 | +function add_users_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1283 | + if (current_user_can('edit_users')) |
|
| 1284 | 1284 | $parent = 'users.php'; |
| 1285 | 1285 | else |
| 1286 | 1286 | $parent = 'profile.php'; |
| 1287 | - return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1287 | + return add_submenu_page($parent, $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1288 | 1288 | } |
| 1289 | 1289 | /** |
| 1290 | 1290 | * Add submenu page to the Dashboard main menu. |
@@ -1302,8 +1302,8 @@ discard block |
||
| 1302 | 1302 | * @param callable $function The function to be called to output the content for this page. |
| 1303 | 1303 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1304 | 1304 | */ |
| 1305 | -function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1306 | - return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1305 | +function add_dashboard_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1306 | + return add_submenu_page('index.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | 1309 | /** |
@@ -1322,8 +1322,8 @@ discard block |
||
| 1322 | 1322 | * @param callable $function The function to be called to output the content for this page. |
| 1323 | 1323 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1324 | 1324 | */ |
| 1325 | -function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1326 | - return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1325 | +function add_posts_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1326 | + return add_submenu_page('edit.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1327 | 1327 | } |
| 1328 | 1328 | |
| 1329 | 1329 | /** |
@@ -1342,8 +1342,8 @@ discard block |
||
| 1342 | 1342 | * @param callable $function The function to be called to output the content for this page. |
| 1343 | 1343 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1344 | 1344 | */ |
| 1345 | -function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1346 | - return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1345 | +function add_media_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1346 | + return add_submenu_page('upload.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1347 | 1347 | } |
| 1348 | 1348 | |
| 1349 | 1349 | /** |
@@ -1362,8 +1362,8 @@ discard block |
||
| 1362 | 1362 | * @param callable $function The function to be called to output the content for this page. |
| 1363 | 1363 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1364 | 1364 | */ |
| 1365 | -function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1366 | - return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1365 | +function add_links_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1366 | + return add_submenu_page('link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1367 | 1367 | } |
| 1368 | 1368 | |
| 1369 | 1369 | /** |
@@ -1382,8 +1382,8 @@ discard block |
||
| 1382 | 1382 | * @param callable $function The function to be called to output the content for this page. |
| 1383 | 1383 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1384 | 1384 | */ |
| 1385 | -function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1386 | - return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1385 | +function add_pages_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1386 | + return add_submenu_page('edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | 1389 | /** |
@@ -1402,8 +1402,8 @@ discard block |
||
| 1402 | 1402 | * @param callable $function The function to be called to output the content for this page. |
| 1403 | 1403 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1404 | 1404 | */ |
| 1405 | -function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1406 | - return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1405 | +function add_comments_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1406 | + return add_submenu_page('edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1407 | 1407 | } |
| 1408 | 1408 | |
| 1409 | 1409 | /** |
@@ -1416,12 +1416,12 @@ discard block |
||
| 1416 | 1416 | * @param string $menu_slug The slug of the menu. |
| 1417 | 1417 | * @return array|bool The removed menu on success, false if not found. |
| 1418 | 1418 | */ |
| 1419 | -function remove_menu_page( $menu_slug ) { |
|
| 1419 | +function remove_menu_page($menu_slug) { |
|
| 1420 | 1420 | global $menu; |
| 1421 | 1421 | |
| 1422 | - foreach ( $menu as $i => $item ) { |
|
| 1423 | - if ( $menu_slug == $item[2] ) { |
|
| 1424 | - unset( $menu[$i] ); |
|
| 1422 | + foreach ($menu as $i => $item) { |
|
| 1423 | + if ($menu_slug == $item[2]) { |
|
| 1424 | + unset($menu[$i]); |
|
| 1425 | 1425 | return $item; |
| 1426 | 1426 | } |
| 1427 | 1427 | } |
@@ -1440,15 +1440,15 @@ discard block |
||
| 1440 | 1440 | * @param string $submenu_slug The slug of the submenu. |
| 1441 | 1441 | * @return array|bool The removed submenu on success, false if not found. |
| 1442 | 1442 | */ |
| 1443 | -function remove_submenu_page( $menu_slug, $submenu_slug ) { |
|
| 1443 | +function remove_submenu_page($menu_slug, $submenu_slug) { |
|
| 1444 | 1444 | global $submenu; |
| 1445 | 1445 | |
| 1446 | - if ( !isset( $submenu[$menu_slug] ) ) |
|
| 1446 | + if ( ! isset($submenu[$menu_slug])) |
|
| 1447 | 1447 | return false; |
| 1448 | 1448 | |
| 1449 | - foreach ( $submenu[$menu_slug] as $i => $item ) { |
|
| 1450 | - if ( $submenu_slug == $item[2] ) { |
|
| 1451 | - unset( $submenu[$menu_slug][$i] ); |
|
| 1449 | + foreach ($submenu[$menu_slug] as $i => $item) { |
|
| 1450 | + if ($submenu_slug == $item[2]) { |
|
| 1451 | + unset($submenu[$menu_slug][$i]); |
|
| 1452 | 1452 | return $item; |
| 1453 | 1453 | } |
| 1454 | 1454 | } |
@@ -1472,12 +1472,12 @@ discard block |
||
| 1472 | 1472 | function menu_page_url($menu_slug, $echo = true) { |
| 1473 | 1473 | global $_parent_pages; |
| 1474 | 1474 | |
| 1475 | - if ( isset( $_parent_pages[$menu_slug] ) ) { |
|
| 1475 | + if (isset($_parent_pages[$menu_slug])) { |
|
| 1476 | 1476 | $parent_slug = $_parent_pages[$menu_slug]; |
| 1477 | - if ( $parent_slug && ! isset( $_parent_pages[$parent_slug] ) ) { |
|
| 1478 | - $url = admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) ); |
|
| 1477 | + if ($parent_slug && ! isset($_parent_pages[$parent_slug])) { |
|
| 1478 | + $url = admin_url(add_query_arg('page', $menu_slug, $parent_slug)); |
|
| 1479 | 1479 | } else { |
| 1480 | - $url = admin_url( 'admin.php?page=' . $menu_slug ); |
|
| 1480 | + $url = admin_url('admin.php?page='.$menu_slug); |
|
| 1481 | 1481 | } |
| 1482 | 1482 | } else { |
| 1483 | 1483 | $url = ''; |
@@ -1485,7 +1485,7 @@ discard block |
||
| 1485 | 1485 | |
| 1486 | 1486 | $url = esc_url($url); |
| 1487 | 1487 | |
| 1488 | - if ( $echo ) |
|
| 1488 | + if ($echo) |
|
| 1489 | 1489 | echo $url; |
| 1490 | 1490 | |
| 1491 | 1491 | return $url; |
@@ -1506,58 +1506,58 @@ discard block |
||
| 1506 | 1506 | * @global array $_wp_menu_nopriv |
| 1507 | 1507 | * @global array $_wp_submenu_nopriv |
| 1508 | 1508 | */ |
| 1509 | -function get_admin_page_parent( $parent = '' ) { |
|
| 1509 | +function get_admin_page_parent($parent = '') { |
|
| 1510 | 1510 | global $parent_file, $menu, $submenu, $pagenow, $typenow, |
| 1511 | 1511 | $plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv; |
| 1512 | 1512 | |
| 1513 | - if ( !empty ( $parent ) && 'admin.php' != $parent ) { |
|
| 1514 | - if ( isset( $_wp_real_parent_file[$parent] ) ) |
|
| 1513 | + if ( ! empty ($parent) && 'admin.php' != $parent) { |
|
| 1514 | + if (isset($_wp_real_parent_file[$parent])) |
|
| 1515 | 1515 | $parent = $_wp_real_parent_file[$parent]; |
| 1516 | 1516 | return $parent; |
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | - if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) { |
|
| 1520 | - foreach ( (array)$menu as $parent_menu ) { |
|
| 1521 | - if ( $parent_menu[2] == $plugin_page ) { |
|
| 1519 | + if ($pagenow == 'admin.php' && isset($plugin_page)) { |
|
| 1520 | + foreach ((array) $menu as $parent_menu) { |
|
| 1521 | + if ($parent_menu[2] == $plugin_page) { |
|
| 1522 | 1522 | $parent_file = $plugin_page; |
| 1523 | - if ( isset( $_wp_real_parent_file[$parent_file] ) ) |
|
| 1523 | + if (isset($_wp_real_parent_file[$parent_file])) |
|
| 1524 | 1524 | $parent_file = $_wp_real_parent_file[$parent_file]; |
| 1525 | 1525 | return $parent_file; |
| 1526 | 1526 | } |
| 1527 | 1527 | } |
| 1528 | - if ( isset( $_wp_menu_nopriv[$plugin_page] ) ) { |
|
| 1528 | + if (isset($_wp_menu_nopriv[$plugin_page])) { |
|
| 1529 | 1529 | $parent_file = $plugin_page; |
| 1530 | - if ( isset( $_wp_real_parent_file[$parent_file] ) ) |
|
| 1530 | + if (isset($_wp_real_parent_file[$parent_file])) |
|
| 1531 | 1531 | $parent_file = $_wp_real_parent_file[$parent_file]; |
| 1532 | 1532 | return $parent_file; |
| 1533 | 1533 | } |
| 1534 | 1534 | } |
| 1535 | 1535 | |
| 1536 | - if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) { |
|
| 1536 | + if (isset($plugin_page) && isset($_wp_submenu_nopriv[$pagenow][$plugin_page])) { |
|
| 1537 | 1537 | $parent_file = $pagenow; |
| 1538 | - if ( isset( $_wp_real_parent_file[$parent_file] ) ) |
|
| 1538 | + if (isset($_wp_real_parent_file[$parent_file])) |
|
| 1539 | 1539 | $parent_file = $_wp_real_parent_file[$parent_file]; |
| 1540 | 1540 | return $parent_file; |
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | - foreach (array_keys( (array)$submenu ) as $parent) { |
|
| 1544 | - foreach ( $submenu[$parent] as $submenu_array ) { |
|
| 1545 | - if ( isset( $_wp_real_parent_file[$parent] ) ) |
|
| 1543 | + foreach (array_keys((array) $submenu) as $parent) { |
|
| 1544 | + foreach ($submenu[$parent] as $submenu_array) { |
|
| 1545 | + if (isset($_wp_real_parent_file[$parent])) |
|
| 1546 | 1546 | $parent = $_wp_real_parent_file[$parent]; |
| 1547 | - if ( !empty($typenow) && ($submenu_array[2] == "$pagenow?post_type=$typenow") ) { |
|
| 1547 | + if ( ! empty($typenow) && ($submenu_array[2] == "$pagenow?post_type=$typenow")) { |
|
| 1548 | 1548 | $parent_file = $parent; |
| 1549 | 1549 | return $parent; |
| 1550 | - } elseif ( $submenu_array[2] == $pagenow && empty($typenow) && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) { |
|
| 1550 | + } elseif ($submenu_array[2] == $pagenow && empty($typenow) && (empty($parent_file) || false === strpos($parent_file, '?'))) { |
|
| 1551 | 1551 | $parent_file = $parent; |
| 1552 | 1552 | return $parent; |
| 1553 | - } elseif ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) { |
|
| 1553 | + } elseif (isset($plugin_page) && ($plugin_page == $submenu_array[2])) { |
|
| 1554 | 1554 | $parent_file = $parent; |
| 1555 | 1555 | return $parent; |
| 1556 | 1556 | } |
| 1557 | 1557 | } |
| 1558 | 1558 | } |
| 1559 | 1559 | |
| 1560 | - if ( empty($parent_file) ) |
|
| 1560 | + if (empty($parent_file)) |
|
| 1561 | 1561 | $parent_file = ''; |
| 1562 | 1562 | return ''; |
| 1563 | 1563 | } |
@@ -1574,20 +1574,20 @@ discard block |
||
| 1574 | 1574 | function get_admin_page_title() { |
| 1575 | 1575 | global $title, $menu, $submenu, $pagenow, $plugin_page, $typenow; |
| 1576 | 1576 | |
| 1577 | - if ( ! empty ( $title ) ) |
|
| 1577 | + if ( ! empty ($title)) |
|
| 1578 | 1578 | return $title; |
| 1579 | 1579 | |
| 1580 | - $hook = get_plugin_page_hook( $plugin_page, $pagenow ); |
|
| 1580 | + $hook = get_plugin_page_hook($plugin_page, $pagenow); |
|
| 1581 | 1581 | |
| 1582 | 1582 | $parent = $parent1 = get_admin_page_parent(); |
| 1583 | 1583 | |
| 1584 | - if ( empty ( $parent) ) { |
|
| 1585 | - foreach ( (array)$menu as $menu_array ) { |
|
| 1586 | - if ( isset( $menu_array[3] ) ) { |
|
| 1587 | - if ( $menu_array[2] == $pagenow ) { |
|
| 1584 | + if (empty ($parent)) { |
|
| 1585 | + foreach ((array) $menu as $menu_array) { |
|
| 1586 | + if (isset($menu_array[3])) { |
|
| 1587 | + if ($menu_array[2] == $pagenow) { |
|
| 1588 | 1588 | $title = $menu_array[3]; |
| 1589 | 1589 | return $menu_array[3]; |
| 1590 | - } elseif ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) { |
|
| 1590 | + } elseif (isset($plugin_page) && ($plugin_page == $menu_array[2]) && ($hook == $menu_array[3])) { |
|
| 1591 | 1591 | $title = $menu_array[3]; |
| 1592 | 1592 | return $menu_array[3]; |
| 1593 | 1593 | } |
@@ -1597,26 +1597,26 @@ discard block |
||
| 1597 | 1597 | } |
| 1598 | 1598 | } |
| 1599 | 1599 | } else { |
| 1600 | - foreach ( array_keys( $submenu ) as $parent ) { |
|
| 1601 | - foreach ( $submenu[$parent] as $submenu_array ) { |
|
| 1602 | - if ( isset( $plugin_page ) && |
|
| 1603 | - ( $plugin_page == $submenu_array[2] ) && |
|
| 1600 | + foreach (array_keys($submenu) as $parent) { |
|
| 1601 | + foreach ($submenu[$parent] as $submenu_array) { |
|
| 1602 | + if (isset($plugin_page) && |
|
| 1603 | + ($plugin_page == $submenu_array[2]) && |
|
| 1604 | 1604 | ( |
| 1605 | - ( $parent == $pagenow ) || |
|
| 1606 | - ( $parent == $plugin_page ) || |
|
| 1607 | - ( $plugin_page == $hook ) || |
|
| 1608 | - ( $pagenow == 'admin.php' && $parent1 != $submenu_array[2] ) || |
|
| 1609 | - ( !empty($typenow) && $parent == $pagenow . '?post_type=' . $typenow) |
|
| 1605 | + ($parent == $pagenow) || |
|
| 1606 | + ($parent == $plugin_page) || |
|
| 1607 | + ($plugin_page == $hook) || |
|
| 1608 | + ($pagenow == 'admin.php' && $parent1 != $submenu_array[2]) || |
|
| 1609 | + ( ! empty($typenow) && $parent == $pagenow.'?post_type='.$typenow) |
|
| 1610 | 1610 | ) |
| 1611 | 1611 | ) { |
| 1612 | 1612 | $title = $submenu_array[3]; |
| 1613 | 1613 | return $submenu_array[3]; |
| 1614 | 1614 | } |
| 1615 | 1615 | |
| 1616 | - if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) // not the current page |
|
| 1616 | + if ($submenu_array[2] != $pagenow || isset($_GET['page'])) // not the current page |
|
| 1617 | 1617 | continue; |
| 1618 | 1618 | |
| 1619 | - if ( isset( $submenu_array[3] ) ) { |
|
| 1619 | + if (isset($submenu_array[3])) { |
|
| 1620 | 1620 | $title = $submenu_array[3]; |
| 1621 | 1621 | return $submenu_array[3]; |
| 1622 | 1622 | } else { |
@@ -1625,12 +1625,12 @@ discard block |
||
| 1625 | 1625 | } |
| 1626 | 1626 | } |
| 1627 | 1627 | } |
| 1628 | - if ( empty ( $title ) ) { |
|
| 1629 | - foreach ( $menu as $menu_array ) { |
|
| 1630 | - if ( isset( $plugin_page ) && |
|
| 1631 | - ( $plugin_page == $menu_array[2] ) && |
|
| 1632 | - ( $pagenow == 'admin.php' ) && |
|
| 1633 | - ( $parent1 == $menu_array[2] ) ) |
|
| 1628 | + if (empty ($title)) { |
|
| 1629 | + foreach ($menu as $menu_array) { |
|
| 1630 | + if (isset($plugin_page) && |
|
| 1631 | + ($plugin_page == $menu_array[2]) && |
|
| 1632 | + ($pagenow == 'admin.php') && |
|
| 1633 | + ($parent1 == $menu_array[2])) |
|
| 1634 | 1634 | { |
| 1635 | 1635 | $title = $menu_array[3]; |
| 1636 | 1636 | return $menu_array[3]; |
@@ -1649,9 +1649,9 @@ discard block |
||
| 1649 | 1649 | * @param string $parent_page |
| 1650 | 1650 | * @return string|null |
| 1651 | 1651 | */ |
| 1652 | -function get_plugin_page_hook( $plugin_page, $parent_page ) { |
|
| 1653 | - $hook = get_plugin_page_hookname( $plugin_page, $parent_page ); |
|
| 1654 | - if ( has_action($hook) ) |
|
| 1652 | +function get_plugin_page_hook($plugin_page, $parent_page) { |
|
| 1653 | + $hook = get_plugin_page_hookname($plugin_page, $parent_page); |
|
| 1654 | + if (has_action($hook)) |
|
| 1655 | 1655 | return $hook; |
| 1656 | 1656 | else |
| 1657 | 1657 | return null; |
@@ -1663,25 +1663,25 @@ discard block |
||
| 1663 | 1663 | * @param string $plugin_page |
| 1664 | 1664 | * @param string $parent_page |
| 1665 | 1665 | */ |
| 1666 | -function get_plugin_page_hookname( $plugin_page, $parent_page ) { |
|
| 1666 | +function get_plugin_page_hookname($plugin_page, $parent_page) { |
|
| 1667 | 1667 | global $admin_page_hooks; |
| 1668 | 1668 | |
| 1669 | - $parent = get_admin_page_parent( $parent_page ); |
|
| 1669 | + $parent = get_admin_page_parent($parent_page); |
|
| 1670 | 1670 | |
| 1671 | 1671 | $page_type = 'admin'; |
| 1672 | - if ( empty ( $parent_page ) || 'admin.php' == $parent_page || isset( $admin_page_hooks[$plugin_page] ) ) { |
|
| 1673 | - if ( isset( $admin_page_hooks[$plugin_page] ) ) { |
|
| 1672 | + if (empty ($parent_page) || 'admin.php' == $parent_page || isset($admin_page_hooks[$plugin_page])) { |
|
| 1673 | + if (isset($admin_page_hooks[$plugin_page])) { |
|
| 1674 | 1674 | $page_type = 'toplevel'; |
| 1675 | - } elseif ( isset( $admin_page_hooks[$parent] )) { |
|
| 1675 | + } elseif (isset($admin_page_hooks[$parent])) { |
|
| 1676 | 1676 | $page_type = $admin_page_hooks[$parent]; |
| 1677 | 1677 | } |
| 1678 | - } elseif ( isset( $admin_page_hooks[$parent] ) ) { |
|
| 1678 | + } elseif (isset($admin_page_hooks[$parent])) { |
|
| 1679 | 1679 | $page_type = $admin_page_hooks[$parent]; |
| 1680 | 1680 | } |
| 1681 | 1681 | |
| 1682 | - $plugin_name = preg_replace( '!\.php!', '', $plugin_page ); |
|
| 1682 | + $plugin_name = preg_replace('!\.php!', '', $plugin_page); |
|
| 1683 | 1683 | |
| 1684 | - return $page_type . '_page_' . $plugin_name; |
|
| 1684 | + return $page_type.'_page_'.$plugin_name; |
|
| 1685 | 1685 | } |
| 1686 | 1686 | |
| 1687 | 1687 | /** |
@@ -1700,49 +1700,49 @@ discard block |
||
| 1700 | 1700 | |
| 1701 | 1701 | $parent = get_admin_page_parent(); |
| 1702 | 1702 | |
| 1703 | - if ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) ) |
|
| 1703 | + if ( ! isset($plugin_page) && isset($_wp_submenu_nopriv[$parent][$pagenow])) |
|
| 1704 | 1704 | return false; |
| 1705 | 1705 | |
| 1706 | - if ( isset( $plugin_page ) ) { |
|
| 1707 | - if ( isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) ) |
|
| 1706 | + if (isset($plugin_page)) { |
|
| 1707 | + if (isset($_wp_submenu_nopriv[$parent][$plugin_page])) |
|
| 1708 | 1708 | return false; |
| 1709 | 1709 | |
| 1710 | 1710 | $hookname = get_plugin_page_hookname($plugin_page, $parent); |
| 1711 | 1711 | |
| 1712 | - if ( !isset($_registered_pages[$hookname]) ) |
|
| 1712 | + if ( ! isset($_registered_pages[$hookname])) |
|
| 1713 | 1713 | return false; |
| 1714 | 1714 | } |
| 1715 | 1715 | |
| 1716 | - if ( empty( $parent) ) { |
|
| 1717 | - if ( isset( $_wp_menu_nopriv[$pagenow] ) ) |
|
| 1716 | + if (empty($parent)) { |
|
| 1717 | + if (isset($_wp_menu_nopriv[$pagenow])) |
|
| 1718 | 1718 | return false; |
| 1719 | - if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) ) |
|
| 1719 | + if (isset($_wp_submenu_nopriv[$pagenow][$pagenow])) |
|
| 1720 | 1720 | return false; |
| 1721 | - if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) |
|
| 1721 | + if (isset($plugin_page) && isset($_wp_submenu_nopriv[$pagenow][$plugin_page])) |
|
| 1722 | 1722 | return false; |
| 1723 | - if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[$plugin_page] ) ) |
|
| 1723 | + if (isset($plugin_page) && isset($_wp_menu_nopriv[$plugin_page])) |
|
| 1724 | 1724 | return false; |
| 1725 | - foreach (array_keys( $_wp_submenu_nopriv ) as $key ) { |
|
| 1726 | - if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) ) |
|
| 1725 | + foreach (array_keys($_wp_submenu_nopriv) as $key) { |
|
| 1726 | + if (isset($_wp_submenu_nopriv[$key][$pagenow])) |
|
| 1727 | 1727 | return false; |
| 1728 | - if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) ) |
|
| 1728 | + if (isset($plugin_page) && isset($_wp_submenu_nopriv[$key][$plugin_page])) |
|
| 1729 | 1729 | return false; |
| 1730 | 1730 | } |
| 1731 | 1731 | return true; |
| 1732 | 1732 | } |
| 1733 | 1733 | |
| 1734 | - if ( isset( $plugin_page ) && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[$plugin_page] ) ) |
|
| 1734 | + if (isset($plugin_page) && ($plugin_page == $parent) && isset($_wp_menu_nopriv[$plugin_page])) |
|
| 1735 | 1735 | return false; |
| 1736 | 1736 | |
| 1737 | - if ( isset( $submenu[$parent] ) ) { |
|
| 1738 | - foreach ( $submenu[$parent] as $submenu_array ) { |
|
| 1739 | - if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) { |
|
| 1740 | - if ( current_user_can( $submenu_array[1] )) |
|
| 1737 | + if (isset($submenu[$parent])) { |
|
| 1738 | + foreach ($submenu[$parent] as $submenu_array) { |
|
| 1739 | + if (isset($plugin_page) && ($submenu_array[2] == $plugin_page)) { |
|
| 1740 | + if (current_user_can($submenu_array[1])) |
|
| 1741 | 1741 | return true; |
| 1742 | 1742 | else |
| 1743 | 1743 | return false; |
| 1744 | - } elseif ( $submenu_array[2] == $pagenow ) { |
|
| 1745 | - if ( current_user_can( $submenu_array[1] )) |
|
| 1744 | + } elseif ($submenu_array[2] == $pagenow) { |
|
| 1745 | + if (current_user_can($submenu_array[1])) |
|
| 1746 | 1746 | return true; |
| 1747 | 1747 | else |
| 1748 | 1748 | return false; |
@@ -1750,9 +1750,9 @@ discard block |
||
| 1750 | 1750 | } |
| 1751 | 1751 | } |
| 1752 | 1752 | |
| 1753 | - foreach ( $menu as $menu_array ) { |
|
| 1754 | - if ( $menu_array[2] == $parent) { |
|
| 1755 | - if ( current_user_can( $menu_array[1] )) |
|
| 1753 | + foreach ($menu as $menu_array) { |
|
| 1754 | + if ($menu_array[2] == $parent) { |
|
| 1755 | + if (current_user_can($menu_array[1])) |
|
| 1756 | 1756 | return true; |
| 1757 | 1757 | else |
| 1758 | 1758 | return false; |
@@ -1776,22 +1776,22 @@ discard block |
||
| 1776 | 1776 | * @param string $option_name The name of an option to sanitize and save. |
| 1777 | 1777 | * @param callable $sanitize_callback A callback function that sanitizes the option's value. |
| 1778 | 1778 | */ |
| 1779 | -function register_setting( $option_group, $option_name, $sanitize_callback = '' ) { |
|
| 1779 | +function register_setting($option_group, $option_name, $sanitize_callback = '') { |
|
| 1780 | 1780 | global $new_whitelist_options; |
| 1781 | 1781 | |
| 1782 | - if ( 'misc' == $option_group ) { |
|
| 1783 | - _deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) ); |
|
| 1782 | + if ('misc' == $option_group) { |
|
| 1783 | + _deprecated_argument(__FUNCTION__, '3.0.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'misc')); |
|
| 1784 | 1784 | $option_group = 'general'; |
| 1785 | 1785 | } |
| 1786 | 1786 | |
| 1787 | - if ( 'privacy' == $option_group ) { |
|
| 1788 | - _deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) ); |
|
| 1787 | + if ('privacy' == $option_group) { |
|
| 1788 | + _deprecated_argument(__FUNCTION__, '3.5.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'privacy')); |
|
| 1789 | 1789 | $option_group = 'reading'; |
| 1790 | 1790 | } |
| 1791 | 1791 | |
| 1792 | - $new_whitelist_options[ $option_group ][] = $option_name; |
|
| 1793 | - if ( $sanitize_callback != '' ) |
|
| 1794 | - add_filter( "sanitize_option_{$option_name}", $sanitize_callback ); |
|
| 1792 | + $new_whitelist_options[$option_group][] = $option_name; |
|
| 1793 | + if ($sanitize_callback != '') |
|
| 1794 | + add_filter("sanitize_option_{$option_name}", $sanitize_callback); |
|
| 1795 | 1795 | } |
| 1796 | 1796 | |
| 1797 | 1797 | /** |
@@ -1805,24 +1805,24 @@ discard block |
||
| 1805 | 1805 | * @param string $option_name |
| 1806 | 1806 | * @param callable $sanitize_callback |
| 1807 | 1807 | */ |
| 1808 | -function unregister_setting( $option_group, $option_name, $sanitize_callback = '' ) { |
|
| 1808 | +function unregister_setting($option_group, $option_name, $sanitize_callback = '') { |
|
| 1809 | 1809 | global $new_whitelist_options; |
| 1810 | 1810 | |
| 1811 | - if ( 'misc' == $option_group ) { |
|
| 1812 | - _deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) ); |
|
| 1811 | + if ('misc' == $option_group) { |
|
| 1812 | + _deprecated_argument(__FUNCTION__, '3.0.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'misc')); |
|
| 1813 | 1813 | $option_group = 'general'; |
| 1814 | 1814 | } |
| 1815 | 1815 | |
| 1816 | - if ( 'privacy' == $option_group ) { |
|
| 1817 | - _deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) ); |
|
| 1816 | + if ('privacy' == $option_group) { |
|
| 1817 | + _deprecated_argument(__FUNCTION__, '3.5.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'privacy')); |
|
| 1818 | 1818 | $option_group = 'reading'; |
| 1819 | 1819 | } |
| 1820 | 1820 | |
| 1821 | - $pos = array_search( $option_name, (array) $new_whitelist_options[ $option_group ] ); |
|
| 1822 | - if ( $pos !== false ) |
|
| 1823 | - unset( $new_whitelist_options[ $option_group ][ $pos ] ); |
|
| 1824 | - if ( $sanitize_callback != '' ) |
|
| 1825 | - remove_filter( "sanitize_option_{$option_name}", $sanitize_callback ); |
|
| 1821 | + $pos = array_search($option_name, (array) $new_whitelist_options[$option_group]); |
|
| 1822 | + if ($pos !== false) |
|
| 1823 | + unset($new_whitelist_options[$option_group][$pos]); |
|
| 1824 | + if ($sanitize_callback != '') |
|
| 1825 | + remove_filter("sanitize_option_{$option_name}", $sanitize_callback); |
|
| 1826 | 1826 | } |
| 1827 | 1827 | |
| 1828 | 1828 | /** |
@@ -1837,11 +1837,11 @@ discard block |
||
| 1837 | 1837 | * @param array $options |
| 1838 | 1838 | * @return array |
| 1839 | 1839 | */ |
| 1840 | -function option_update_filter( $options ) { |
|
| 1840 | +function option_update_filter($options) { |
|
| 1841 | 1841 | global $new_whitelist_options; |
| 1842 | 1842 | |
| 1843 | - if ( is_array( $new_whitelist_options ) ) |
|
| 1844 | - $options = add_option_whitelist( $new_whitelist_options, $options ); |
|
| 1843 | + if (is_array($new_whitelist_options)) |
|
| 1844 | + $options = add_option_whitelist($new_whitelist_options, $options); |
|
| 1845 | 1845 | |
| 1846 | 1846 | return $options; |
| 1847 | 1847 | } |
@@ -1857,21 +1857,21 @@ discard block |
||
| 1857 | 1857 | * @param string|array $options |
| 1858 | 1858 | * @return array |
| 1859 | 1859 | */ |
| 1860 | -function add_option_whitelist( $new_options, $options = '' ) { |
|
| 1861 | - if ( $options == '' ) |
|
| 1860 | +function add_option_whitelist($new_options, $options = '') { |
|
| 1861 | + if ($options == '') |
|
| 1862 | 1862 | global $whitelist_options; |
| 1863 | 1863 | else |
| 1864 | 1864 | $whitelist_options = $options; |
| 1865 | 1865 | |
| 1866 | - foreach ( $new_options as $page => $keys ) { |
|
| 1867 | - foreach ( $keys as $key ) { |
|
| 1868 | - if ( !isset($whitelist_options[ $page ]) || !is_array($whitelist_options[ $page ]) ) { |
|
| 1869 | - $whitelist_options[ $page ] = array(); |
|
| 1870 | - $whitelist_options[ $page ][] = $key; |
|
| 1866 | + foreach ($new_options as $page => $keys) { |
|
| 1867 | + foreach ($keys as $key) { |
|
| 1868 | + if ( ! isset($whitelist_options[$page]) || ! is_array($whitelist_options[$page])) { |
|
| 1869 | + $whitelist_options[$page] = array(); |
|
| 1870 | + $whitelist_options[$page][] = $key; |
|
| 1871 | 1871 | } else { |
| 1872 | - $pos = array_search( $key, $whitelist_options[ $page ] ); |
|
| 1873 | - if ( $pos === false ) |
|
| 1874 | - $whitelist_options[ $page ][] = $key; |
|
| 1872 | + $pos = array_search($key, $whitelist_options[$page]); |
|
| 1873 | + if ($pos === false) |
|
| 1874 | + $whitelist_options[$page][] = $key; |
|
| 1875 | 1875 | } |
| 1876 | 1876 | } |
| 1877 | 1877 | } |
@@ -1890,18 +1890,18 @@ discard block |
||
| 1890 | 1890 | * @param string|array $options |
| 1891 | 1891 | * @return array |
| 1892 | 1892 | */ |
| 1893 | -function remove_option_whitelist( $del_options, $options = '' ) { |
|
| 1894 | - if ( $options == '' ) |
|
| 1893 | +function remove_option_whitelist($del_options, $options = '') { |
|
| 1894 | + if ($options == '') |
|
| 1895 | 1895 | global $whitelist_options; |
| 1896 | 1896 | else |
| 1897 | 1897 | $whitelist_options = $options; |
| 1898 | 1898 | |
| 1899 | - foreach ( $del_options as $page => $keys ) { |
|
| 1900 | - foreach ( $keys as $key ) { |
|
| 1901 | - if ( isset($whitelist_options[ $page ]) && is_array($whitelist_options[ $page ]) ) { |
|
| 1902 | - $pos = array_search( $key, $whitelist_options[ $page ] ); |
|
| 1903 | - if ( $pos !== false ) |
|
| 1904 | - unset( $whitelist_options[ $page ][ $pos ] ); |
|
| 1899 | + foreach ($del_options as $page => $keys) { |
|
| 1900 | + foreach ($keys as $key) { |
|
| 1901 | + if (isset($whitelist_options[$page]) && is_array($whitelist_options[$page])) { |
|
| 1902 | + $pos = array_search($key, $whitelist_options[$page]); |
|
| 1903 | + if ($pos !== false) |
|
| 1904 | + unset($whitelist_options[$page][$pos]); |
|
| 1905 | 1905 | } |
| 1906 | 1906 | } |
| 1907 | 1907 | } |
@@ -1917,7 +1917,7 @@ discard block |
||
| 1917 | 1917 | * @param string $option_group A settings group name. This should match the group name used in register_setting(). |
| 1918 | 1918 | */ |
| 1919 | 1919 | function settings_fields($option_group) { |
| 1920 | - echo "<input type='hidden' name='option_page' value='" . esc_attr($option_group) . "' />"; |
|
| 1920 | + echo "<input type='hidden' name='option_page' value='".esc_attr($option_group)."' />"; |
|
| 1921 | 1921 | echo '<input type="hidden" name="action" value="update" />'; |
| 1922 | 1922 | wp_nonce_field("$option_group-options"); |
| 1923 | 1923 | } |
@@ -1929,16 +1929,16 @@ discard block |
||
| 1929 | 1929 | * |
| 1930 | 1930 | * @param bool $clear_update_cache Whether to clear the Plugin updates cache |
| 1931 | 1931 | */ |
| 1932 | -function wp_clean_plugins_cache( $clear_update_cache = true ) { |
|
| 1933 | - if ( $clear_update_cache ) |
|
| 1934 | - delete_site_transient( 'update_plugins' ); |
|
| 1935 | - wp_cache_delete( 'plugins', 'plugins' ); |
|
| 1932 | +function wp_clean_plugins_cache($clear_update_cache = true) { |
|
| 1933 | + if ($clear_update_cache) |
|
| 1934 | + delete_site_transient('update_plugins'); |
|
| 1935 | + wp_cache_delete('plugins', 'plugins'); |
|
| 1936 | 1936 | } |
| 1937 | 1937 | |
| 1938 | 1938 | /** |
| 1939 | 1939 | * @param string $plugin |
| 1940 | 1940 | */ |
| 1941 | -function plugin_sandbox_scrape( $plugin ) { |
|
| 1942 | - wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); |
|
| 1943 | - include( WP_PLUGIN_DIR . '/' . $plugin ); |
|
| 1941 | +function plugin_sandbox_scrape($plugin) { |
|
| 1942 | + wp_register_plugin_realpath(WP_PLUGIN_DIR.'/'.$plugin); |
|
| 1943 | + include(WP_PLUGIN_DIR.'/'.$plugin); |
|
| 1944 | 1944 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @type array $args Extra meta box arguments. |
| 20 | 20 | * } |
| 21 | 21 | */ |
| 22 | -function post_submit_meta_box( $post, $args = array() ) { |
|
| 22 | +function post_submit_meta_box($post, $args = array()) { |
|
| 23 | 23 | global $action; |
| 24 | 24 | |
| 25 | 25 | $post_type = $post->post_type; |
@@ -32,27 +32,27 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?> |
| 34 | 34 | <div style="display:none;"> |
| 35 | -<?php submit_button( __( 'Save' ), 'button', 'save' ); ?> |
|
| 35 | +<?php submit_button(__('Save'), 'button', 'save'); ?> |
|
| 36 | 36 | </div> |
| 37 | 37 | |
| 38 | 38 | <div id="minor-publishing-actions"> |
| 39 | 39 | <div id="save-action"> |
| 40 | -<?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> |
|
| 41 | -<input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" class="button" /> |
|
| 40 | +<?php if ('publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status) { ?> |
|
| 41 | +<input <?php if ('private' == $post->post_status) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" class="button" /> |
|
| 42 | 42 | <span class="spinner"></span> |
| 43 | -<?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?> |
|
| 43 | +<?php } elseif ('pending' == $post->post_status && $can_publish) { ?> |
|
| 44 | 44 | <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" class="button" /> |
| 45 | 45 | <span class="spinner"></span> |
| 46 | 46 | <?php } ?> |
| 47 | 47 | </div> |
| 48 | -<?php if ( is_post_type_viewable( $post_type_object ) ) : ?> |
|
| 48 | +<?php if (is_post_type_viewable($post_type_object)) : ?> |
|
| 49 | 49 | <div id="preview-action"> |
| 50 | 50 | <?php |
| 51 | -$preview_link = esc_url( get_preview_post_link( $post ) ); |
|
| 52 | -if ( 'publish' == $post->post_status ) { |
|
| 53 | - $preview_button = __( 'Preview Changes' ); |
|
| 51 | +$preview_link = esc_url(get_preview_post_link($post)); |
|
| 52 | +if ('publish' == $post->post_status) { |
|
| 53 | + $preview_button = __('Preview Changes'); |
|
| 54 | 54 | } else { |
| 55 | - $preview_button = __( 'Preview' ); |
|
| 55 | + $preview_button = __('Preview'); |
|
| 56 | 56 | } |
| 57 | 57 | ?> |
| 58 | 58 | <a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview-<?php echo (int) $post->ID; ?>" id="post-preview"><?php echo $preview_button; ?></a> |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @param WP_Post $post WP_Post object for the current post. |
| 69 | 69 | */ |
| 70 | -do_action( 'post_submitbox_minor_actions', $post ); |
|
| 70 | +do_action('post_submitbox_minor_actions', $post); |
|
| 71 | 71 | ?> |
| 72 | 72 | <div class="clear"></div> |
| 73 | 73 | </div><!-- #minor-publishing-actions --> |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | <div class="misc-pub-section misc-pub-post-status"><label for="post_status"><?php _e('Status:') ?></label> |
| 78 | 78 | <span id="post-status-display"> |
| 79 | 79 | <?php |
| 80 | -switch ( $post->post_status ) { |
|
| 80 | +switch ($post->post_status) { |
|
| 81 | 81 | case 'private': |
| 82 | 82 | _e('Privately Published'); |
| 83 | 83 | break; |
@@ -97,24 +97,24 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | ?> |
| 99 | 99 | </span> |
| 100 | -<?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?> |
|
| 101 | -<a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit status' ); ?></span></a> |
|
| 100 | +<?php if ('publish' == $post->post_status || 'private' == $post->post_status || $can_publish) { ?> |
|
| 101 | +<a href="#post_status" <?php if ('private' == $post->post_status) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js"><span aria-hidden="true"><?php _e('Edit'); ?></span> <span class="screen-reader-text"><?php _e('Edit status'); ?></span></a> |
|
| 102 | 102 | |
| 103 | 103 | <div id="post-status-select" class="hide-if-js"> |
| 104 | -<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ('auto-draft' == $post->post_status ) ? 'draft' : $post->post_status); ?>" /> |
|
| 104 | +<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr(('auto-draft' == $post->post_status) ? 'draft' : $post->post_status); ?>" /> |
|
| 105 | 105 | <select name='post_status' id='post_status'> |
| 106 | -<?php if ( 'publish' == $post->post_status ) : ?> |
|
| 107 | -<option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option> |
|
| 108 | -<?php elseif ( 'private' == $post->post_status ) : ?> |
|
| 109 | -<option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option> |
|
| 110 | -<?php elseif ( 'future' == $post->post_status ) : ?> |
|
| 111 | -<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option> |
|
| 106 | +<?php if ('publish' == $post->post_status) : ?> |
|
| 107 | +<option<?php selected($post->post_status, 'publish'); ?> value='publish'><?php _e('Published') ?></option> |
|
| 108 | +<?php elseif ('private' == $post->post_status) : ?> |
|
| 109 | +<option<?php selected($post->post_status, 'private'); ?> value='publish'><?php _e('Privately Published') ?></option> |
|
| 110 | +<?php elseif ('future' == $post->post_status) : ?> |
|
| 111 | +<option<?php selected($post->post_status, 'future'); ?> value='future'><?php _e('Scheduled') ?></option> |
|
| 112 | 112 | <?php endif; ?> |
| 113 | -<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option> |
|
| 114 | -<?php if ( 'auto-draft' == $post->post_status ) : ?> |
|
| 115 | -<option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e('Draft') ?></option> |
|
| 113 | +<option<?php selected($post->post_status, 'pending'); ?> value='pending'><?php _e('Pending Review') ?></option> |
|
| 114 | +<?php if ('auto-draft' == $post->post_status) : ?> |
|
| 115 | +<option<?php selected($post->post_status, 'auto-draft'); ?> value='draft'><?php _e('Draft') ?></option> |
|
| 116 | 116 | <?php else : ?> |
| 117 | -<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option> |
|
| 117 | +<option<?php selected($post->post_status, 'draft'); ?> value='draft'><?php _e('Draft') ?></option> |
|
| 118 | 118 | <?php endif; ?> |
| 119 | 119 | </select> |
| 120 | 120 | <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a> |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | <div class="misc-pub-section misc-pub-visibility" id="visibility"> |
| 128 | 128 | <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php |
| 129 | 129 | |
| 130 | -if ( 'private' == $post->post_status ) { |
|
| 130 | +if ('private' == $post->post_status) { |
|
| 131 | 131 | $post->post_password = ''; |
| 132 | 132 | $visibility = 'private'; |
| 133 | 133 | $visibility_trans = __('Private'); |
| 134 | -} elseif ( !empty( $post->post_password ) ) { |
|
| 134 | +} elseif ( ! empty($post->post_password)) { |
|
| 135 | 135 | $visibility = 'password'; |
| 136 | 136 | $visibility_trans = __('Password protected'); |
| 137 | -} elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) { |
|
| 137 | +} elseif ($post_type == 'post' && is_sticky($post->ID)) { |
|
| 138 | 138 | $visibility = 'public'; |
| 139 | 139 | $visibility_trans = __('Public, Sticky'); |
| 140 | 140 | } else { |
@@ -142,23 +142,23 @@ discard block |
||
| 142 | 142 | $visibility_trans = __('Public'); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | -echo esc_html( $visibility_trans ); ?></span> |
|
| 146 | -<?php if ( $can_publish ) { ?> |
|
| 147 | -<a href="#visibility" class="edit-visibility hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit visibility' ); ?></span></a> |
|
| 145 | +echo esc_html($visibility_trans); ?></span> |
|
| 146 | +<?php if ($can_publish) { ?> |
|
| 147 | +<a href="#visibility" class="edit-visibility hide-if-no-js"><span aria-hidden="true"><?php _e('Edit'); ?></span> <span class="screen-reader-text"><?php _e('Edit visibility'); ?></span></a> |
|
| 148 | 148 | |
| 149 | 149 | <div id="post-visibility-select" class="hide-if-js"> |
| 150 | 150 | <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" /> |
| 151 | 151 | <?php if ($post_type == 'post'): ?> |
| 152 | 152 | <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> /> |
| 153 | 153 | <?php endif; ?> |
| 154 | -<input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" /> |
|
| 155 | -<input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br /> |
|
| 156 | -<?php if ( $post_type == 'post' && current_user_can( 'edit_others_posts' ) ) : ?> |
|
| 157 | -<span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked( is_sticky( $post->ID ) ); ?> /> <label for="sticky" class="selectit"><?php _e( 'Stick this post to the front page' ); ?></label><br /></span> |
|
| 154 | +<input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr($visibility); ?>" /> |
|
| 155 | +<input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked($visibility, 'public'); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br /> |
|
| 156 | +<?php if ($post_type == 'post' && current_user_can('edit_others_posts')) : ?> |
|
| 157 | +<span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID)); ?> /> <label for="sticky" class="selectit"><?php _e('Stick this post to the front page'); ?></label><br /></span> |
|
| 158 | 158 | <?php endif; ?> |
| 159 | -<input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br /> |
|
| 159 | +<input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked($visibility, 'password'); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br /> |
|
| 160 | 160 | <span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>" maxlength="20" /><br /></span> |
| 161 | -<input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br /> |
|
| 161 | +<input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked($visibility, 'private'); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br /> |
|
| 162 | 162 | |
| 163 | 163 | <p> |
| 164 | 164 | <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a> |
@@ -171,40 +171,40 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | <?php |
| 173 | 173 | /* translators: Publish box date format, see https://secure.php.net/date */ |
| 174 | -$datef = __( 'M j, Y @ H:i' ); |
|
| 175 | -if ( 0 != $post->ID ) { |
|
| 176 | - if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date |
|
| 174 | +$datef = __('M j, Y @ H:i'); |
|
| 175 | +if (0 != $post->ID) { |
|
| 176 | + if ('future' == $post->post_status) { // scheduled for publishing at a future date |
|
| 177 | 177 | $stamp = __('Scheduled for: <b>%1$s</b>'); |
| 178 | - } elseif ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published |
|
| 178 | + } elseif ('publish' == $post->post_status || 'private' == $post->post_status) { // already published |
|
| 179 | 179 | $stamp = __('Published on: <b>%1$s</b>'); |
| 180 | - } elseif ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified |
|
| 180 | + } elseif ('0000-00-00 00:00:00' == $post->post_date_gmt) { // draft, 1 or more saves, no date specified |
|
| 181 | 181 | $stamp = __('Publish <b>immediately</b>'); |
| 182 | - } elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified |
|
| 182 | + } elseif (time() < strtotime($post->post_date_gmt.' +0000')) { // draft, 1 or more saves, future date specified |
|
| 183 | 183 | $stamp = __('Schedule for: <b>%1$s</b>'); |
| 184 | 184 | } else { // draft, 1 or more saves, date specified |
| 185 | 185 | $stamp = __('Publish on: <b>%1$s</b>'); |
| 186 | 186 | } |
| 187 | - $date = date_i18n( $datef, strtotime( $post->post_date ) ); |
|
| 187 | + $date = date_i18n($datef, strtotime($post->post_date)); |
|
| 188 | 188 | } else { // draft (no saves, and thus no date specified) |
| 189 | 189 | $stamp = __('Publish <b>immediately</b>'); |
| 190 | - $date = date_i18n( $datef, strtotime( current_time('mysql') ) ); |
|
| 190 | + $date = date_i18n($datef, strtotime(current_time('mysql'))); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | -if ( ! empty( $args['args']['revisions_count'] ) ) : ?> |
|
| 193 | +if ( ! empty($args['args']['revisions_count'])) : ?> |
|
| 194 | 194 | <div class="misc-pub-section misc-pub-revisions"> |
| 195 | - <?php printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '</b>' ); ?> |
|
| 196 | - <a class="hide-if-no-js" href="<?php echo esc_url( get_edit_post_link( $args['args']['revision_id'] ) ); ?>"><span aria-hidden="true"><?php _ex( 'Browse', 'revisions' ); ?></span> <span class="screen-reader-text"><?php _e( 'Browse revisions' ); ?></span></a> |
|
| 195 | + <?php printf(__('Revisions: %s'), '<b>'.number_format_i18n($args['args']['revisions_count']).'</b>'); ?> |
|
| 196 | + <a class="hide-if-no-js" href="<?php echo esc_url(get_edit_post_link($args['args']['revision_id'])); ?>"><span aria-hidden="true"><?php _ex('Browse', 'revisions'); ?></span> <span class="screen-reader-text"><?php _e('Browse revisions'); ?></span></a> |
|
| 197 | 197 | </div> |
| 198 | 198 | <?php endif; |
| 199 | 199 | |
| 200 | -if ( $can_publish ) : // Contributors don't get to choose the date of publish ?> |
|
| 200 | +if ($can_publish) : // Contributors don't get to choose the date of publish ?> |
|
| 201 | 201 | <div class="misc-pub-section curtime misc-pub-curtime"> |
| 202 | 202 | <span id="timestamp"> |
| 203 | 203 | <?php printf($stamp, $date); ?></span> |
| 204 | - <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit date and time' ); ?></span></a> |
|
| 204 | + <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><span aria-hidden="true"><?php _e('Edit'); ?></span> <span class="screen-reader-text"><?php _e('Edit date and time'); ?></span></a> |
|
| 205 | 205 | <fieldset id="timestampdiv" class="hide-if-js"> |
| 206 | - <legend class="screen-reader-text"><?php _e( 'Date and time' ); ?></legend> |
|
| 207 | - <?php touch_time( ( $action === 'edit' ), 1 ); ?> |
|
| 206 | + <legend class="screen-reader-text"><?php _e('Date and time'); ?></legend> |
|
| 207 | + <?php touch_time(($action === 'edit'), 1); ?> |
|
| 208 | 208 | </fieldset> |
| 209 | 209 | </div><?php // /misc-pub-section ?> |
| 210 | 210 | <?php endif; ?> |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @param WP_Post $post WP_Post object for the current post. |
| 220 | 220 | */ |
| 221 | -do_action( 'post_submitbox_misc_actions', $post ); |
|
| 221 | +do_action('post_submitbox_misc_actions', $post); |
|
| 222 | 222 | ?> |
| 223 | 223 | </div> |
| 224 | 224 | <div class="clear"></div> |
@@ -231,12 +231,12 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @since 2.7.0 |
| 233 | 233 | */ |
| 234 | -do_action( 'post_submitbox_start' ); |
|
| 234 | +do_action('post_submitbox_start'); |
|
| 235 | 235 | ?> |
| 236 | 236 | <div id="delete-action"> |
| 237 | 237 | <?php |
| 238 | -if ( current_user_can( "delete_post", $post->ID ) ) { |
|
| 239 | - if ( !EMPTY_TRASH_DAYS ) |
|
| 238 | +if (current_user_can("delete_post", $post->ID)) { |
|
| 239 | + if ( ! EMPTY_TRASH_DAYS) |
|
| 240 | 240 | $delete_text = __('Delete Permanently'); |
| 241 | 241 | else |
| 242 | 242 | $delete_text = __('Move to Trash'); |
@@ -248,23 +248,23 @@ discard block |
||
| 248 | 248 | <div id="publishing-action"> |
| 249 | 249 | <span class="spinner"></span> |
| 250 | 250 | <?php |
| 251 | -if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { |
|
| 252 | - if ( $can_publish ) : |
|
| 253 | - if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> |
|
| 251 | +if ( ! in_array($post->post_status, array('publish', 'future', 'private')) || 0 == $post->ID) { |
|
| 252 | + if ($can_publish) : |
|
| 253 | + if ( ! empty($post->post_date_gmt) && time() < strtotime($post->post_date_gmt.' +0000')) : ?> |
|
| 254 | 254 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" /> |
| 255 | - <?php submit_button( __( 'Schedule' ), 'primary button-large', 'publish', false ); ?> |
|
| 255 | + <?php submit_button(__('Schedule'), 'primary button-large', 'publish', false); ?> |
|
| 256 | 256 | <?php else : ?> |
| 257 | 257 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" /> |
| 258 | - <?php submit_button( __( 'Publish' ), 'primary button-large', 'publish', false ); ?> |
|
| 258 | + <?php submit_button(__('Publish'), 'primary button-large', 'publish', false); ?> |
|
| 259 | 259 | <?php endif; |
| 260 | 260 | else : ?> |
| 261 | 261 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" /> |
| 262 | - <?php submit_button( __( 'Submit for Review' ), 'primary button-large', 'publish', false ); ?> |
|
| 262 | + <?php submit_button(__('Submit for Review'), 'primary button-large', 'publish', false); ?> |
|
| 263 | 263 | <?php |
| 264 | 264 | endif; |
| 265 | 265 | } else { ?> |
| 266 | 266 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" /> |
| 267 | - <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ) ?>" /> |
|
| 267 | + <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e('Update') ?>" /> |
|
| 268 | 268 | <?php |
| 269 | 269 | } ?> |
| 270 | 270 | </div> |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * |
| 283 | 283 | * @param object $post |
| 284 | 284 | */ |
| 285 | -function attachment_submit_meta_box( $post ) { |
|
| 285 | +function attachment_submit_meta_box($post) { |
|
| 286 | 286 | ?> |
| 287 | 287 | <div class="submitbox" id="submitpost"> |
| 288 | 288 | |
@@ -290,16 +290,16 @@ discard block |
||
| 290 | 290 | |
| 291 | 291 | <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?> |
| 292 | 292 | <div style="display:none;"> |
| 293 | -<?php submit_button( __( 'Save' ), 'button', 'save' ); ?> |
|
| 293 | +<?php submit_button(__('Save'), 'button', 'save'); ?> |
|
| 294 | 294 | </div> |
| 295 | 295 | |
| 296 | 296 | |
| 297 | 297 | <div id="misc-publishing-actions"> |
| 298 | 298 | <?php |
| 299 | 299 | /* translators: Publish box date format, see https://secure.php.net/date */ |
| 300 | - $datef = __( 'M j, Y @ H:i' ); |
|
| 300 | + $datef = __('M j, Y @ H:i'); |
|
| 301 | 301 | $stamp = __('Uploaded on: <b>%1$s</b>'); |
| 302 | - $date = date_i18n( $datef, strtotime( $post->post_date ) ); |
|
| 302 | + $date = date_i18n($datef, strtotime($post->post_date)); |
|
| 303 | 303 | ?> |
| 304 | 304 | <div class="misc-pub-section curtime misc-pub-curtime"> |
| 305 | 305 | <span id="timestamp"><?php printf($stamp, $date); ?></span> |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * |
| 313 | 313 | * @since 3.5.0 |
| 314 | 314 | */ |
| 315 | - do_action( 'attachment_submitbox_misc_actions' ); |
|
| 315 | + do_action('attachment_submitbox_misc_actions'); |
|
| 316 | 316 | ?> |
| 317 | 317 | </div><!-- #misc-publishing-actions --> |
| 318 | 318 | <div class="clear"></div> |
@@ -321,12 +321,12 @@ discard block |
||
| 321 | 321 | <div id="major-publishing-actions"> |
| 322 | 322 | <div id="delete-action"> |
| 323 | 323 | <?php |
| 324 | - if ( current_user_can( 'delete_post', $post->ID ) ) |
|
| 325 | - if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { |
|
| 326 | - echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . _x( 'Trash', 'verb' ) . "</a>"; |
|
| 324 | + if (current_user_can('delete_post', $post->ID)) |
|
| 325 | + if (EMPTY_TRASH_DAYS && MEDIA_TRASH) { |
|
| 326 | + echo "<a class='submitdelete deletion' href='".get_delete_post_link($post->ID)."'>"._x('Trash', 'verb')."</a>"; |
|
| 327 | 327 | } else { |
| 328 | 328 | $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; |
| 329 | - echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "'>" . __( 'Delete Permanently' ) . "</a>"; |
|
| 329 | + echo "<a class='submitdelete deletion'$delete_ays href='".get_delete_post_link($post->ID, null, true)."'>".__('Delete Permanently')."</a>"; |
|
| 330 | 330 | } |
| 331 | 331 | ?> |
| 332 | 332 | </div> |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | <div id="publishing-action"> |
| 335 | 335 | <span class="spinner"></span> |
| 336 | 336 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" /> |
| 337 | - <input name="save" type="submit" class="button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ) ?>" /> |
|
| 337 | + <input name="save" type="submit" class="button-primary button-large" id="publish" value="<?php esc_attr_e('Update') ?>" /> |
|
| 338 | 338 | </div> |
| 339 | 339 | <div class="clear"></div> |
| 340 | 340 | </div><!-- #major-publishing-actions --> |
@@ -359,24 +359,24 @@ discard block |
||
| 359 | 359 | * @type array $args Extra meta box arguments. |
| 360 | 360 | * } |
| 361 | 361 | */ |
| 362 | -function post_format_meta_box( $post, $box ) { |
|
| 363 | - if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) : |
|
| 364 | - $post_formats = get_theme_support( 'post-formats' ); |
|
| 362 | +function post_format_meta_box($post, $box) { |
|
| 363 | + if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) : |
|
| 364 | + $post_formats = get_theme_support('post-formats'); |
|
| 365 | 365 | |
| 366 | - if ( is_array( $post_formats[0] ) ) : |
|
| 367 | - $post_format = get_post_format( $post->ID ); |
|
| 368 | - if ( !$post_format ) |
|
| 366 | + if (is_array($post_formats[0])) : |
|
| 367 | + $post_format = get_post_format($post->ID); |
|
| 368 | + if ( ! $post_format) |
|
| 369 | 369 | $post_format = '0'; |
| 370 | 370 | // Add in the current one if it isn't there yet, in case the current theme doesn't support it |
| 371 | - if ( $post_format && !in_array( $post_format, $post_formats[0] ) ) |
|
| 371 | + if ($post_format && ! in_array($post_format, $post_formats[0])) |
|
| 372 | 372 | $post_formats[0][] = $post_format; |
| 373 | 373 | ?> |
| 374 | 374 | <div id="post-formats-select"> |
| 375 | 375 | <fieldset> |
| 376 | - <legend class="screen-reader-text"><?php _e( 'Post Formats' ); ?></legend> |
|
| 377 | - <input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> <label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string( 'standard' ); ?></label> |
|
| 378 | - <?php foreach ( $post_formats[0] as $format ) : ?> |
|
| 379 | - <br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $post_format, $format ); ?> /> <label for="post-format-<?php echo esc_attr( $format ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label> |
|
| 376 | + <legend class="screen-reader-text"><?php _e('Post Formats'); ?></legend> |
|
| 377 | + <input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked($post_format, '0'); ?> /> <label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string('standard'); ?></label> |
|
| 378 | + <?php foreach ($post_formats[0] as $format) : ?> |
|
| 379 | + <br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr($format); ?>" value="<?php echo esc_attr($format); ?>" <?php checked($post_format, $format); ?> /> <label for="post-format-<?php echo esc_attr($format); ?>" class="post-format-icon post-format-<?php echo esc_attr($format); ?>"><?php echo esc_html(get_post_format_string($format)); ?></label> |
|
| 380 | 380 | <?php endforeach; ?> |
| 381 | 381 | </fieldset> |
| 382 | 382 | </div> |
@@ -404,20 +404,20 @@ discard block |
||
| 404 | 404 | * } |
| 405 | 405 | * } |
| 406 | 406 | */ |
| 407 | -function post_tags_meta_box( $post, $box ) { |
|
| 408 | - $defaults = array( 'taxonomy' => 'post_tag' ); |
|
| 409 | - if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { |
|
| 407 | +function post_tags_meta_box($post, $box) { |
|
| 408 | + $defaults = array('taxonomy' => 'post_tag'); |
|
| 409 | + if ( ! isset($box['args']) || ! is_array($box['args'])) { |
|
| 410 | 410 | $args = array(); |
| 411 | 411 | } else { |
| 412 | 412 | $args = $box['args']; |
| 413 | 413 | } |
| 414 | - $r = wp_parse_args( $args, $defaults ); |
|
| 415 | - $tax_name = esc_attr( $r['taxonomy'] ); |
|
| 416 | - $taxonomy = get_taxonomy( $r['taxonomy'] ); |
|
| 417 | - $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms ); |
|
| 418 | - $comma = _x( ',', 'tag delimiter' ); |
|
| 419 | - $terms_to_edit = get_terms_to_edit( $post->ID, $tax_name ); |
|
| 420 | - if ( ! is_string( $terms_to_edit ) ) { |
|
| 414 | + $r = wp_parse_args($args, $defaults); |
|
| 415 | + $tax_name = esc_attr($r['taxonomy']); |
|
| 416 | + $taxonomy = get_taxonomy($r['taxonomy']); |
|
| 417 | + $user_can_assign_terms = current_user_can($taxonomy->cap->assign_terms); |
|
| 418 | + $comma = _x(',', 'tag delimiter'); |
|
| 419 | + $terms_to_edit = get_terms_to_edit($post->ID, $tax_name); |
|
| 420 | + if ( ! is_string($terms_to_edit)) { |
|
| 421 | 421 | $terms_to_edit = ''; |
| 422 | 422 | } |
| 423 | 423 | ?> |
@@ -425,9 +425,9 @@ discard block |
||
| 425 | 425 | <div class="jaxtag"> |
| 426 | 426 | <div class="nojs-tags hide-if-js"> |
| 427 | 427 | <label for="tax-input-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_or_remove_items; ?></label> |
| 428 | - <p><textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php disabled( ! $user_can_assign_terms ); ?> aria-describedby="new-tag-<?php echo $tax_name; ?>-desc"><?php echo str_replace( ',', $comma . ' ', $terms_to_edit ); // textarea_escaped by esc_attr() ?></textarea></p> |
|
| 428 | + <p><textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php disabled( ! $user_can_assign_terms); ?> aria-describedby="new-tag-<?php echo $tax_name; ?>-desc"><?php echo str_replace(',', $comma.' ', $terms_to_edit); // textarea_escaped by esc_attr() ?></textarea></p> |
|
| 429 | 429 | </div> |
| 430 | - <?php if ( $user_can_assign_terms ) : ?> |
|
| 430 | + <?php if ($user_can_assign_terms) : ?> |
|
| 431 | 431 | <div class="ajaxtag hide-if-no-js"> |
| 432 | 432 | <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label> |
| 433 | 433 | <p><input type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" aria-describedby="new-tag-<?php echo $tax_name; ?>-desc" value="" /> |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | </div> |
| 439 | 439 | <div class="tagchecklist"></div> |
| 440 | 440 | </div> |
| 441 | -<?php if ( $user_can_assign_terms ) : ?> |
|
| 441 | +<?php if ($user_can_assign_terms) : ?> |
|
| 442 | 442 | <p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->choose_from_most_used; ?></a></p> |
| 443 | 443 | <?php endif; ?> |
| 444 | 444 | <?php |
@@ -465,49 +465,49 @@ discard block |
||
| 465 | 465 | * } |
| 466 | 466 | * } |
| 467 | 467 | */ |
| 468 | -function post_categories_meta_box( $post, $box ) { |
|
| 469 | - $defaults = array( 'taxonomy' => 'category' ); |
|
| 470 | - if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { |
|
| 468 | +function post_categories_meta_box($post, $box) { |
|
| 469 | + $defaults = array('taxonomy' => 'category'); |
|
| 470 | + if ( ! isset($box['args']) || ! is_array($box['args'])) { |
|
| 471 | 471 | $args = array(); |
| 472 | 472 | } else { |
| 473 | 473 | $args = $box['args']; |
| 474 | 474 | } |
| 475 | - $r = wp_parse_args( $args, $defaults ); |
|
| 476 | - $tax_name = esc_attr( $r['taxonomy'] ); |
|
| 477 | - $taxonomy = get_taxonomy( $r['taxonomy'] ); |
|
| 475 | + $r = wp_parse_args($args, $defaults); |
|
| 476 | + $tax_name = esc_attr($r['taxonomy']); |
|
| 477 | + $taxonomy = get_taxonomy($r['taxonomy']); |
|
| 478 | 478 | ?> |
| 479 | 479 | <div id="taxonomy-<?php echo $tax_name; ?>" class="categorydiv"> |
| 480 | 480 | <ul id="<?php echo $tax_name; ?>-tabs" class="category-tabs"> |
| 481 | 481 | <li class="tabs"><a href="#<?php echo $tax_name; ?>-all"><?php echo $taxonomy->labels->all_items; ?></a></li> |
| 482 | - <li class="hide-if-no-js"><a href="#<?php echo $tax_name; ?>-pop"><?php _e( 'Most Used' ); ?></a></li> |
|
| 482 | + <li class="hide-if-no-js"><a href="#<?php echo $tax_name; ?>-pop"><?php _e('Most Used'); ?></a></li> |
|
| 483 | 483 | </ul> |
| 484 | 484 | |
| 485 | 485 | <div id="<?php echo $tax_name; ?>-pop" class="tabs-panel" style="display: none;"> |
| 486 | 486 | <ul id="<?php echo $tax_name; ?>checklist-pop" class="categorychecklist form-no-clear" > |
| 487 | - <?php $popular_ids = wp_popular_terms_checklist( $tax_name ); ?> |
|
| 487 | + <?php $popular_ids = wp_popular_terms_checklist($tax_name); ?> |
|
| 488 | 488 | </ul> |
| 489 | 489 | </div> |
| 490 | 490 | |
| 491 | 491 | <div id="<?php echo $tax_name; ?>-all" class="tabs-panel"> |
| 492 | 492 | <?php |
| 493 | - $name = ( $tax_name == 'category' ) ? 'post_category' : 'tax_input[' . $tax_name . ']'; |
|
| 493 | + $name = ($tax_name == 'category') ? 'post_category' : 'tax_input['.$tax_name.']'; |
|
| 494 | 494 | echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. |
| 495 | 495 | ?> |
| 496 | 496 | <ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear"> |
| 497 | - <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => $tax_name, 'popular_cats' => $popular_ids ) ); ?> |
|
| 497 | + <?php wp_terms_checklist($post->ID, array('taxonomy' => $tax_name, 'popular_cats' => $popular_ids)); ?> |
|
| 498 | 498 | </ul> |
| 499 | 499 | </div> |
| 500 | - <?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?> |
|
| 500 | + <?php if (current_user_can($taxonomy->cap->edit_terms)) : ?> |
|
| 501 | 501 | <div id="<?php echo $tax_name; ?>-adder" class="wp-hidden-children"> |
| 502 | 502 | <a id="<?php echo $tax_name; ?>-add-toggle" href="#<?php echo $tax_name; ?>-add" class="hide-if-no-js taxonomy-add-new"> |
| 503 | 503 | <?php |
| 504 | 504 | /* translators: %s: add new taxonomy label */ |
| 505 | - printf( __( '+ %s' ), $taxonomy->labels->add_new_item ); |
|
| 505 | + printf(__('+ %s'), $taxonomy->labels->add_new_item); |
|
| 506 | 506 | ?> |
| 507 | 507 | </a> |
| 508 | 508 | <p id="<?php echo $tax_name; ?>-add" class="category-add wp-hidden-child"> |
| 509 | 509 | <label class="screen-reader-text" for="new<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label> |
| 510 | - <input type="text" name="new<?php echo $tax_name; ?>" id="new<?php echo $tax_name; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $taxonomy->labels->new_item_name ); ?>" aria-required="true"/> |
|
| 510 | + <input type="text" name="new<?php echo $tax_name; ?>" id="new<?php echo $tax_name; ?>" class="form-required form-input-tip" value="<?php echo esc_attr($taxonomy->labels->new_item_name); ?>" aria-required="true"/> |
|
| 511 | 511 | <label class="screen-reader-text" for="new<?php echo $tax_name; ?>_parent"> |
| 512 | 512 | <?php echo $taxonomy->labels->parent_item_colon; ?> |
| 513 | 513 | </label> |
@@ -515,10 +515,10 @@ discard block |
||
| 515 | 515 | $parent_dropdown_args = array( |
| 516 | 516 | 'taxonomy' => $tax_name, |
| 517 | 517 | 'hide_empty' => 0, |
| 518 | - 'name' => 'new' . $tax_name . '_parent', |
|
| 518 | + 'name' => 'new'.$tax_name.'_parent', |
|
| 519 | 519 | 'orderby' => 'name', |
| 520 | 520 | 'hierarchical' => 1, |
| 521 | - 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', |
|
| 521 | + 'show_option_none' => '— '.$taxonomy->labels->parent_item.' —', |
|
| 522 | 522 | ); |
| 523 | 523 | |
| 524 | 524 | /** |
@@ -545,12 +545,12 @@ discard block |
||
| 545 | 545 | * taxonomy label. |
| 546 | 546 | * } |
| 547 | 547 | */ |
| 548 | - $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args ); |
|
| 548 | + $parent_dropdown_args = apply_filters('post_edit_category_parent_dropdown_args', $parent_dropdown_args); |
|
| 549 | 549 | |
| 550 | - wp_dropdown_categories( $parent_dropdown_args ); |
|
| 550 | + wp_dropdown_categories($parent_dropdown_args); |
|
| 551 | 551 | ?> |
| 552 | - <input type="button" id="<?php echo $tax_name; ?>-add-submit" data-wp-lists="add:<?php echo $tax_name; ?>checklist:<?php echo $tax_name; ?>-add" class="button category-add-submit" value="<?php echo esc_attr( $taxonomy->labels->add_new_item ); ?>" /> |
|
| 553 | - <?php wp_nonce_field( 'add-' . $tax_name, '_ajax_nonce-add-' . $tax_name, false ); ?> |
|
| 552 | + <input type="button" id="<?php echo $tax_name; ?>-add-submit" data-wp-lists="add:<?php echo $tax_name; ?>checklist:<?php echo $tax_name; ?>-add" class="button category-add-submit" value="<?php echo esc_attr($taxonomy->labels->add_new_item); ?>" /> |
|
| 553 | + <?php wp_nonce_field('add-'.$tax_name, '_ajax_nonce-add-'.$tax_name, false); ?> |
|
| 554 | 554 | <span id="<?php echo $tax_name; ?>-ajax-response"></span> |
| 555 | 555 | </p> |
| 556 | 556 | </div> |
@@ -572,8 +572,8 @@ discard block |
||
| 572 | 572 | <p><?php |
| 573 | 573 | printf( |
| 574 | 574 | /* translators: %s: Codex URL */ |
| 575 | - __( 'Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="%s">Learn more about manual excerpts</a>.' ), |
|
| 576 | - __( 'https://codex.wordpress.org/Excerpt' ) |
|
| 575 | + __('Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="%s">Learn more about manual excerpts</a>.'), |
|
| 576 | + __('https://codex.wordpress.org/Excerpt') |
|
| 577 | 577 | ); |
| 578 | 578 | ?></p> |
| 579 | 579 | <?php |
@@ -587,32 +587,32 @@ discard block |
||
| 587 | 587 | * @param object $post |
| 588 | 588 | */ |
| 589 | 589 | function post_trackback_meta_box($post) { |
| 590 | - $form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" value="' . |
|
| 591 | - esc_attr( str_replace( "\n", ' ', $post->to_ping ) ) . '" aria-describedby="trackback-url-desc" />'; |
|
| 590 | + $form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" value="'. |
|
| 591 | + esc_attr(str_replace("\n", ' ', $post->to_ping)).'" aria-describedby="trackback-url-desc" />'; |
|
| 592 | 592 | if ('' != $post->pinged) { |
| 593 | - $pings = '<p>'. __('Already pinged:') . '</p><ul>'; |
|
| 593 | + $pings = '<p>'.__('Already pinged:').'</p><ul>'; |
|
| 594 | 594 | $already_pinged = explode("\n", trim($post->pinged)); |
| 595 | 595 | foreach ($already_pinged as $pinged_url) { |
| 596 | - $pings .= "\n\t<li>" . esc_html($pinged_url) . "</li>"; |
|
| 596 | + $pings .= "\n\t<li>".esc_html($pinged_url)."</li>"; |
|
| 597 | 597 | } |
| 598 | 598 | $pings .= '</ul>'; |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | ?> |
| 602 | 602 | <p> |
| 603 | - <label for="trackback_url"><?php _e( 'Send trackbacks to:' ); ?></label> |
|
| 603 | + <label for="trackback_url"><?php _e('Send trackbacks to:'); ?></label> |
|
| 604 | 604 | <?php echo $form_trackback; ?> |
| 605 | 605 | </p> |
| 606 | -<p id="trackback-url-desc" class="howto"><?php _e( 'Separate multiple URLs with spaces' ); ?></p> |
|
| 606 | +<p id="trackback-url-desc" class="howto"><?php _e('Separate multiple URLs with spaces'); ?></p> |
|
| 607 | 607 | <p><?php |
| 608 | 608 | printf( |
| 609 | 609 | /* translators: %s: Codex URL */ |
| 610 | - __( 'Trackbacks are a way to notify legacy blog systems that you’ve linked to them. If you link other WordPress sites, they’ll be notified automatically using <a href="%s">pingbacks</a>, no other action necessary.' ), |
|
| 611 | - __( 'https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' ) |
|
| 610 | + __('Trackbacks are a way to notify legacy blog systems that you’ve linked to them. If you link other WordPress sites, they’ll be notified automatically using <a href="%s">pingbacks</a>, no other action necessary.'), |
|
| 611 | + __('https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments') |
|
| 612 | 612 | ); |
| 613 | 613 | ?></p> |
| 614 | 614 | <?php |
| 615 | -if ( ! empty($pings) ) |
|
| 615 | +if ( ! empty($pings)) |
|
| 616 | 616 | echo $pings; |
| 617 | 617 | } |
| 618 | 618 | |
@@ -629,18 +629,18 @@ discard block |
||
| 629 | 629 | <div id="ajax-response"></div> |
| 630 | 630 | <?php |
| 631 | 631 | $metadata = has_meta($post->ID); |
| 632 | -foreach ( $metadata as $key => $value ) { |
|
| 633 | - if ( is_protected_meta( $metadata[ $key ][ 'meta_key' ], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ][ 'meta_key' ] ) ) |
|
| 634 | - unset( $metadata[ $key ] ); |
|
| 632 | +foreach ($metadata as $key => $value) { |
|
| 633 | + if (is_protected_meta($metadata[$key]['meta_key'], 'post') || ! current_user_can('edit_post_meta', $post->ID, $metadata[$key]['meta_key'])) |
|
| 634 | + unset($metadata[$key]); |
|
| 635 | 635 | } |
| 636 | -list_meta( $metadata ); |
|
| 637 | -meta_form( $post ); ?> |
|
| 636 | +list_meta($metadata); |
|
| 637 | +meta_form($post); ?> |
|
| 638 | 638 | </div> |
| 639 | 639 | <p><?php |
| 640 | 640 | printf( |
| 641 | 641 | /* translators: %s: Codex URL */ |
| 642 | - __( 'Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.' ), |
|
| 643 | - __( 'https://codex.wordpress.org/Using_Custom_Fields' ) |
|
| 642 | + __('Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.'), |
|
| 643 | + __('https://codex.wordpress.org/Using_Custom_Fields') |
|
| 644 | 644 | ); |
| 645 | 645 | ?></p> |
| 646 | 646 | <?php |
@@ -657,12 +657,12 @@ discard block |
||
| 657 | 657 | ?> |
| 658 | 658 | <input name="advanced_view" type="hidden" value="1" /> |
| 659 | 659 | <p class="meta-options"> |
| 660 | - <label for="comment_status" class="selectit"><input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e( 'Allow comments.' ) ?></label><br /> |
|
| 660 | + <label for="comment_status" class="selectit"><input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e('Allow comments.') ?></label><br /> |
|
| 661 | 661 | <label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php |
| 662 | 662 | printf( |
| 663 | 663 | /* translators: %s: Codex URL */ |
| 664 | - __( 'Allow <a href="%s">trackbacks and pingbacks</a> on this page.' ), |
|
| 665 | - __( 'https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' ) ); |
|
| 664 | + __('Allow <a href="%s">trackbacks and pingbacks</a> on this page.'), |
|
| 665 | + __('https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments') ); |
|
| 666 | 666 | ?></label> |
| 667 | 667 | <?php |
| 668 | 668 | /** |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | * |
| 673 | 673 | * @param WP_Post $post WP_Post object of the current post. |
| 674 | 674 | */ |
| 675 | - do_action( 'post_comment_status_meta_box-options', $post ); |
|
| 675 | + do_action('post_comment_status_meta_box-options', $post); |
|
| 676 | 676 | ?> |
| 677 | 677 | </p> |
| 678 | 678 | <?php |
@@ -698,21 +698,21 @@ discard block |
||
| 698 | 698 | * |
| 699 | 699 | * @param object $post |
| 700 | 700 | */ |
| 701 | -function post_comment_meta_box( $post ) { |
|
| 702 | - wp_nonce_field( 'get-comments', 'add_comment_nonce', false ); |
|
| 701 | +function post_comment_meta_box($post) { |
|
| 702 | + wp_nonce_field('get-comments', 'add_comment_nonce', false); |
|
| 703 | 703 | ?> |
| 704 | 704 | <p class="hide-if-no-js" id="add-new-comment"><a class="button" href="#commentstatusdiv" onclick="window.commentReply && commentReply.addcomment(<?php echo $post->ID; ?>);return false;"><?php _e('Add comment'); ?></a></p> |
| 705 | 705 | <?php |
| 706 | 706 | |
| 707 | - $total = get_comments( array( 'post_id' => $post->ID, 'number' => 1, 'count' => true ) ); |
|
| 707 | + $total = get_comments(array('post_id' => $post->ID, 'number' => 1, 'count' => true)); |
|
| 708 | 708 | $wp_list_table = _get_list_table('WP_Post_Comments_List_Table'); |
| 709 | - $wp_list_table->display( true ); |
|
| 709 | + $wp_list_table->display(true); |
|
| 710 | 710 | |
| 711 | - if ( 1 > $total ) { |
|
| 712 | - echo '<p id="no-comments">' . __('No comments yet.') . '</p>'; |
|
| 711 | + if (1 > $total) { |
|
| 712 | + echo '<p id="no-comments">'.__('No comments yet.').'</p>'; |
|
| 713 | 713 | } else { |
| 714 | - $hidden = get_hidden_meta_boxes( get_current_screen() ); |
|
| 715 | - if ( ! in_array('commentsdiv', $hidden) ) { |
|
| 714 | + $hidden = get_hidden_meta_boxes(get_current_screen()); |
|
| 715 | + if ( ! in_array('commentsdiv', $hidden)) { |
|
| 716 | 716 | ?> |
| 717 | 717 | <script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script> |
| 718 | 718 | <?php |
@@ -735,9 +735,9 @@ discard block |
||
| 735 | 735 | */ |
| 736 | 736 | function post_slug_meta_box($post) { |
| 737 | 737 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
| 738 | -$editable_slug = apply_filters( 'editable_slug', $post->post_name, $post ); |
|
| 738 | +$editable_slug = apply_filters('editable_slug', $post->post_name, $post); |
|
| 739 | 739 | ?> |
| 740 | -<label class="screen-reader-text" for="post_name"><?php _e('Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( $editable_slug ); ?>" /> |
|
| 740 | +<label class="screen-reader-text" for="post_name"><?php _e('Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr($editable_slug); ?>" /> |
|
| 741 | 741 | <?php |
| 742 | 742 | } |
| 743 | 743 | |
@@ -755,13 +755,13 @@ discard block |
||
| 755 | 755 | ?> |
| 756 | 756 | <label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label> |
| 757 | 757 | <?php |
| 758 | - wp_dropdown_users( array( |
|
| 758 | + wp_dropdown_users(array( |
|
| 759 | 759 | 'who' => 'authors', |
| 760 | 760 | 'name' => 'post_author_override', |
| 761 | 761 | 'selected' => empty($post->ID) ? $user_ID : $post->post_author, |
| 762 | 762 | 'include_selected' => true, |
| 763 | 763 | 'show' => 'display_name_with_login', |
| 764 | - ) ); |
|
| 764 | + )); |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | /** |
@@ -771,8 +771,8 @@ discard block |
||
| 771 | 771 | * |
| 772 | 772 | * @param object $post |
| 773 | 773 | */ |
| 774 | -function post_revisions_meta_box( $post ) { |
|
| 775 | - wp_list_post_revisions( $post ); |
|
| 774 | +function post_revisions_meta_box($post) { |
|
| 775 | + wp_list_post_revisions($post); |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | // -- Page related Meta Boxes |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | */ |
| 787 | 787 | function page_attributes_meta_box($post) { |
| 788 | 788 | $post_type_object = get_post_type_object($post->post_type); |
| 789 | - if ( $post_type_object->hierarchical ) { |
|
| 789 | + if ($post_type_object->hierarchical) { |
|
| 790 | 790 | $dropdown_args = array( |
| 791 | 791 | 'post_type' => $post->post_type, |
| 792 | 792 | 'exclude_tree' => $post->ID, |
@@ -807,9 +807,9 @@ discard block |
||
| 807 | 807 | * @param array $dropdown_args Array of arguments used to generate the pages drop-down. |
| 808 | 808 | * @param WP_Post $post The current WP_Post object. |
| 809 | 809 | */ |
| 810 | - $dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post ); |
|
| 811 | - $pages = wp_dropdown_pages( $dropdown_args ); |
|
| 812 | - if ( ! empty($pages) ) { |
|
| 810 | + $dropdown_args = apply_filters('page_attributes_dropdown_pages_args', $dropdown_args, $post); |
|
| 811 | + $pages = wp_dropdown_pages($dropdown_args); |
|
| 812 | + if ( ! empty($pages)) { |
|
| 813 | 813 | ?> |
| 814 | 814 | <p><strong><?php _e('Parent') ?></strong></p> |
| 815 | 815 | <label class="screen-reader-text" for="parent_id"><?php _e('Parent') ?></label> |
@@ -817,8 +817,8 @@ discard block |
||
| 817 | 817 | <?php |
| 818 | 818 | } // end empty pages check |
| 819 | 819 | } // end hierarchical check. |
| 820 | - if ( 'page' == $post->post_type && 0 != count( get_page_templates( $post ) ) && get_option( 'page_for_posts' ) != $post->ID ) { |
|
| 821 | - $template = !empty($post->page_template) ? $post->page_template : false; |
|
| 820 | + if ('page' == $post->post_type && 0 != count(get_page_templates($post)) && get_option('page_for_posts') != $post->ID) { |
|
| 821 | + $template = ! empty($post->page_template) ? $post->page_template : false; |
|
| 822 | 822 | ?> |
| 823 | 823 | <p><strong><?php _e('Template') ?></strong><?php |
| 824 | 824 | /** |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | * @param string $template The template used for the current post. |
| 831 | 831 | * @param WP_Post $post The current post. |
| 832 | 832 | */ |
| 833 | - do_action( 'page_attributes_meta_box_template', $template, $post ); |
|
| 833 | + do_action('page_attributes_meta_box_template', $template, $post); |
|
| 834 | 834 | ?></p> |
| 835 | 835 | <label class="screen-reader-text" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template"> |
| 836 | 836 | <?php |
@@ -843,17 +843,17 @@ discard block |
||
| 843 | 843 | * @param string $context Where the option label is displayed. Possible values |
| 844 | 844 | * include 'meta-box' or 'quick-edit'. |
| 845 | 845 | */ |
| 846 | -$default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'meta-box' ); |
|
| 846 | +$default_title = apply_filters('default_page_template_title', __('Default Template'), 'meta-box'); |
|
| 847 | 847 | ?> |
| 848 | -<option value="default"><?php echo esc_html( $default_title ); ?></option> |
|
| 848 | +<option value="default"><?php echo esc_html($default_title); ?></option> |
|
| 849 | 849 | <?php page_template_dropdown($template); ?> |
| 850 | 850 | </select> |
| 851 | 851 | <?php |
| 852 | 852 | } ?> |
| 853 | 853 | <p><strong><?php _e('Order') ?></strong></p> |
| 854 | 854 | <p><label class="screen-reader-text" for="menu_order"><?php _e('Order') ?></label><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr($post->menu_order) ?>" /></p> |
| 855 | -<?php if ( 'page' == $post->post_type && get_current_screen()->get_help_tabs() ) { ?> |
|
| 856 | -<p><?php _e( 'Need help? Use the Help tab above the screen title.' ); ?></p> |
|
| 855 | +<?php if ('page' == $post->post_type && get_current_screen()->get_help_tabs()) { ?> |
|
| 856 | +<p><?php _e('Need help? Use the Help tab above the screen title.'); ?></p> |
|
| 857 | 857 | <?php |
| 858 | 858 | } |
| 859 | 859 | } |
@@ -875,12 +875,12 @@ discard block |
||
| 875 | 875 | |
| 876 | 876 | <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?> |
| 877 | 877 | <div style="display:none;"> |
| 878 | -<?php submit_button( __( 'Save' ), 'button', 'save', false ); ?> |
|
| 878 | +<?php submit_button(__('Save'), 'button', 'save', false); ?> |
|
| 879 | 879 | </div> |
| 880 | 880 | |
| 881 | 881 | <div id="minor-publishing-actions"> |
| 882 | 882 | <div id="preview-action"> |
| 883 | -<?php if ( !empty($link->link_id) ) { ?> |
|
| 883 | +<?php if ( ! empty($link->link_id)) { ?> |
|
| 884 | 884 | <a class="preview button" href="<?php echo $link->link_url; ?>" target="_blank"><?php _e('Visit Link'); ?></a> |
| 885 | 885 | <?php } ?> |
| 886 | 886 | </div> |
@@ -898,20 +898,20 @@ discard block |
||
| 898 | 898 | <div id="major-publishing-actions"> |
| 899 | 899 | <?php |
| 900 | 900 | /** This action is documented in wp-admin/includes/meta-boxes.php */ |
| 901 | -do_action( 'post_submitbox_start' ); |
|
| 901 | +do_action('post_submitbox_start'); |
|
| 902 | 902 | ?> |
| 903 | 903 | <div id="delete-action"> |
| 904 | 904 | <?php |
| 905 | -if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links') ) { ?> |
|
| 906 | - <a class="submitdelete deletion" href="<?php echo wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf(__("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a> |
|
| 905 | +if ( ! empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links')) { ?> |
|
| 906 | + <a class="submitdelete deletion" href="<?php echo wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_'.$link->link_id); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf(__("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name)); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a> |
|
| 907 | 907 | <?php } ?> |
| 908 | 908 | </div> |
| 909 | 909 | |
| 910 | 910 | <div id="publishing-action"> |
| 911 | -<?php if ( !empty($link->link_id) ) { ?> |
|
| 912 | - <input name="save" type="submit" class="button-large button-primary" id="publish" value="<?php esc_attr_e( 'Update Link' ) ?>" /> |
|
| 911 | +<?php if ( ! empty($link->link_id)) { ?> |
|
| 912 | + <input name="save" type="submit" class="button-large button-primary" id="publish" value="<?php esc_attr_e('Update Link') ?>" /> |
|
| 913 | 913 | <?php } else { ?> |
| 914 | - <input name="save" type="submit" class="button-large button-primary" id="publish" value="<?php esc_attr_e( 'Add Link' ) ?>" /> |
|
| 914 | + <input name="save" type="submit" class="button-large button-primary" id="publish" value="<?php esc_attr_e('Add Link') ?>" /> |
|
| 915 | 915 | <?php } ?> |
| 916 | 916 | </div> |
| 917 | 917 | <div class="clear"></div> |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | * |
| 923 | 923 | * @since 2.5.0 |
| 924 | 924 | */ |
| 925 | -do_action( 'submitlink_box' ); |
|
| 925 | +do_action('submitlink_box'); |
|
| 926 | 926 | ?> |
| 927 | 927 | <div class="clear"></div> |
| 928 | 928 | </div> |
@@ -940,14 +940,14 @@ discard block |
||
| 940 | 940 | ?> |
| 941 | 941 | <div id="taxonomy-linkcategory" class="categorydiv"> |
| 942 | 942 | <ul id="category-tabs" class="category-tabs"> |
| 943 | - <li class="tabs"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li> |
|
| 944 | - <li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li> |
|
| 943 | + <li class="tabs"><a href="#categories-all"><?php _e('All Categories'); ?></a></li> |
|
| 944 | + <li class="hide-if-no-js"><a href="#categories-pop"><?php _e('Most Used'); ?></a></li> |
|
| 945 | 945 | </ul> |
| 946 | 946 | |
| 947 | 947 | <div id="categories-all" class="tabs-panel"> |
| 948 | 948 | <ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear"> |
| 949 | 949 | <?php |
| 950 | - if ( isset($link->link_id) ) |
|
| 950 | + if (isset($link->link_id)) |
|
| 951 | 951 | wp_link_category_checklist($link->link_id); |
| 952 | 952 | else |
| 953 | 953 | wp_link_category_checklist(); |
@@ -962,12 +962,12 @@ discard block |
||
| 962 | 962 | </div> |
| 963 | 963 | |
| 964 | 964 | <div id="category-adder" class="wp-hidden-children"> |
| 965 | - <a id="category-add-toggle" href="#category-add" class="taxonomy-add-new"><?php _e( '+ Add New Category' ); ?></a> |
|
| 965 | + <a id="category-add-toggle" href="#category-add" class="taxonomy-add-new"><?php _e('+ Add New Category'); ?></a> |
|
| 966 | 966 | <p id="link-category-add" class="wp-hidden-child"> |
| 967 | - <label class="screen-reader-text" for="newcat"><?php _e( '+ Add New Category' ); ?></label> |
|
| 968 | - <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" aria-required="true" /> |
|
| 969 | - <input type="button" id="link-category-add-submit" data-wp-lists="add:categorychecklist:link-category-add" class="button" value="<?php esc_attr_e( 'Add' ); ?>" /> |
|
| 970 | - <?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?> |
|
| 967 | + <label class="screen-reader-text" for="newcat"><?php _e('+ Add New Category'); ?></label> |
|
| 968 | + <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e('New category name'); ?>" aria-required="true" /> |
|
| 969 | + <input type="button" id="link-category-add-submit" data-wp-lists="add:categorychecklist:link-category-add" class="button" value="<?php esc_attr_e('Add'); ?>" /> |
|
| 970 | + <?php wp_nonce_field('add-link-category', '_ajax_nonce', false); ?> |
|
| 971 | 971 | <span id="category-ajax-response"></span> |
| 972 | 972 | </p> |
| 973 | 973 | </div> |
@@ -985,13 +985,13 @@ discard block |
||
| 985 | 985 | function link_target_meta_box($link) { ?> |
| 986 | 986 | <fieldset><legend class="screen-reader-text"><span><?php _e('Target') ?></span></legend> |
| 987 | 987 | <p><label for="link_target_blank" class="selectit"> |
| 988 | -<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> /> |
|
| 988 | +<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo (isset($link->link_target) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> /> |
|
| 989 | 989 | <?php _e('<code>_blank</code> — new window or tab.'); ?></label></p> |
| 990 | 990 | <p><label for="link_target_top" class="selectit"> |
| 991 | -<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> /> |
|
| 991 | +<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo (isset($link->link_target) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> /> |
|
| 992 | 992 | <?php _e('<code>_top</code> — current window or tab, with no frames.'); ?></label></p> |
| 993 | 993 | <p><label for="link_target_none" class="selectit"> |
| 994 | -<input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> /> |
|
| 994 | +<input id="link_target_none" type="radio" name="link_target" value="" <?php echo (isset($link->link_target) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> /> |
|
| 995 | 995 | <?php _e('<code>_none</code> — same window or tab.'); ?></label></p> |
| 996 | 996 | </fieldset> |
| 997 | 997 | <p><?php _e('Choose the target frame for your link.'); ?></p> |
@@ -1009,16 +1009,16 @@ discard block |
||
| 1009 | 1009 | * @param string $value |
| 1010 | 1010 | * @param mixed $deprecated Never used. |
| 1011 | 1011 | */ |
| 1012 | -function xfn_check( $class, $value = '', $deprecated = '' ) { |
|
| 1012 | +function xfn_check($class, $value = '', $deprecated = '') { |
|
| 1013 | 1013 | global $link; |
| 1014 | 1014 | |
| 1015 | - if ( !empty( $deprecated ) ) |
|
| 1016 | - _deprecated_argument( __FUNCTION__, '0.0.0' ); // Never implemented |
|
| 1015 | + if ( ! empty($deprecated)) |
|
| 1016 | + _deprecated_argument(__FUNCTION__, '0.0.0'); // Never implemented |
|
| 1017 | 1017 | |
| 1018 | - $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; |
|
| 1018 | + $link_rel = isset($link->link_rel) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; |
|
| 1019 | 1019 | $rels = preg_split('/\s+/', $link_rel); |
| 1020 | 1020 | |
| 1021 | - if ('' != $value && in_array($value, $rels) ) { |
|
| 1021 | + if ('' != $value && in_array($value, $rels)) { |
|
| 1022 | 1022 | echo ' checked="checked"'; |
| 1023 | 1023 | } |
| 1024 | 1024 | |
@@ -1026,7 +1026,7 @@ discard block |
||
| 1026 | 1026 | if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"'; |
| 1027 | 1027 | if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"'; |
| 1028 | 1028 | if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"'; |
| 1029 | - if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"'; |
|
| 1029 | + if ('identity' == $class && in_array('me', $rels)) echo ' checked="checked"'; |
|
| 1030 | 1030 | } |
| 1031 | 1031 | } |
| 1032 | 1032 | |
@@ -1042,7 +1042,7 @@ discard block |
||
| 1042 | 1042 | <table class="links-table"> |
| 1043 | 1043 | <tr> |
| 1044 | 1044 | <th scope="row"><label for="link_rel"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('rel:') ?></label></th> |
| 1045 | - <td><input type="text" name="link_rel" id="link_rel" value="<?php echo ( isset( $link->link_rel ) ? esc_attr($link->link_rel) : ''); ?>" /></td> |
|
| 1045 | + <td><input type="text" name="link_rel" id="link_rel" value="<?php echo (isset($link->link_rel) ? esc_attr($link->link_rel) : ''); ?>" /></td> |
|
| 1046 | 1046 | </tr> |
| 1047 | 1047 | <tr> |
| 1048 | 1048 | <th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?></th> |
@@ -1160,25 +1160,25 @@ discard block |
||
| 1160 | 1160 | <table class="links-table" cellpadding="0"> |
| 1161 | 1161 | <tr> |
| 1162 | 1162 | <th scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th> |
| 1163 | - <td><input type="text" name="link_image" class="code" id="link_image" maxlength="255" value="<?php echo ( isset( $link->link_image ) ? esc_attr($link->link_image) : ''); ?>" /></td> |
|
| 1163 | + <td><input type="text" name="link_image" class="code" id="link_image" maxlength="255" value="<?php echo (isset($link->link_image) ? esc_attr($link->link_image) : ''); ?>" /></td> |
|
| 1164 | 1164 | </tr> |
| 1165 | 1165 | <tr> |
| 1166 | 1166 | <th scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th> |
| 1167 | - <td><input name="link_rss" class="code" type="text" id="rss_uri" maxlength="255" value="<?php echo ( isset( $link->link_rss ) ? esc_attr($link->link_rss) : ''); ?>" /></td> |
|
| 1167 | + <td><input name="link_rss" class="code" type="text" id="rss_uri" maxlength="255" value="<?php echo (isset($link->link_rss) ? esc_attr($link->link_rss) : ''); ?>" /></td> |
|
| 1168 | 1168 | </tr> |
| 1169 | 1169 | <tr> |
| 1170 | 1170 | <th scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th> |
| 1171 | - <td><textarea name="link_notes" id="link_notes" rows="10"><?php echo ( isset( $link->link_notes ) ? $link->link_notes : ''); // textarea_escaped ?></textarea></td> |
|
| 1171 | + <td><textarea name="link_notes" id="link_notes" rows="10"><?php echo (isset($link->link_notes) ? $link->link_notes : ''); // textarea_escaped ?></textarea></td> |
|
| 1172 | 1172 | </tr> |
| 1173 | 1173 | <tr> |
| 1174 | 1174 | <th scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th> |
| 1175 | 1175 | <td><select name="link_rating" id="link_rating" size="1"> |
| 1176 | 1176 | <?php |
| 1177 | - for ( $r = 0; $r <= 10; $r++ ) { |
|
| 1178 | - echo '<option value="' . $r . '"'; |
|
| 1179 | - if ( isset($link->link_rating) && $link->link_rating == $r ) |
|
| 1177 | + for ($r = 0; $r <= 10; $r++) { |
|
| 1178 | + echo '<option value="'.$r.'"'; |
|
| 1179 | + if (isset($link->link_rating) && $link->link_rating == $r) |
|
| 1180 | 1180 | echo ' selected="selected"'; |
| 1181 | - echo('>' . $r . '</option>'); |
|
| 1181 | + echo('>'.$r.'</option>'); |
|
| 1182 | 1182 | } |
| 1183 | 1183 | ?></select> <?php _e('(Leave at 0 for no rating.)') ?> |
| 1184 | 1184 | </td> |
@@ -1194,9 +1194,9 @@ discard block |
||
| 1194 | 1194 | * |
| 1195 | 1195 | * @param WP_Post $post A post object. |
| 1196 | 1196 | */ |
| 1197 | -function post_thumbnail_meta_box( $post ) { |
|
| 1198 | - $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true ); |
|
| 1199 | - echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID ); |
|
| 1197 | +function post_thumbnail_meta_box($post) { |
|
| 1198 | + $thumbnail_id = get_post_meta($post->ID, '_thumbnail_id', true); |
|
| 1199 | + echo _wp_post_thumbnail_html($thumbnail_id, $post->ID); |
|
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | 1202 | /** |
@@ -1206,18 +1206,18 @@ discard block |
||
| 1206 | 1206 | * |
| 1207 | 1207 | * @param WP_Post $post A post object. |
| 1208 | 1208 | */ |
| 1209 | -function attachment_id3_data_meta_box( $post ) { |
|
| 1209 | +function attachment_id3_data_meta_box($post) { |
|
| 1210 | 1210 | $meta = array(); |
| 1211 | - if ( ! empty( $post->ID ) ) { |
|
| 1212 | - $meta = wp_get_attachment_metadata( $post->ID ); |
|
| 1211 | + if ( ! empty($post->ID)) { |
|
| 1212 | + $meta = wp_get_attachment_metadata($post->ID); |
|
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | - foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) : ?> |
|
| 1215 | + foreach (wp_get_attachment_id3_keys($post, 'edit') as $key => $label) : ?> |
|
| 1216 | 1216 | <p> |
| 1217 | 1217 | <label for="title"><?php echo $label ?></label><br /> |
| 1218 | - <input type="text" name="id3_<?php echo esc_attr( $key ) ?>" id="id3_<?php echo esc_attr( $key ) ?>" class="large-text" value="<?php |
|
| 1219 | - if ( ! empty( $meta[ $key ] ) ) { |
|
| 1220 | - echo esc_attr( $meta[ $key ] ); |
|
| 1218 | + <input type="text" name="id3_<?php echo esc_attr($key) ?>" id="id3_<?php echo esc_attr($key) ?>" class="large-text" value="<?php |
|
| 1219 | + if ( ! empty($meta[$key])) { |
|
| 1220 | + echo esc_attr($meta[$key]); |
|
| 1221 | 1221 | } |
| 1222 | 1222 | ?>" /> |
| 1223 | 1223 | </p> |
@@ -113,8 +113,11 @@ discard block |
||
| 113 | 113 | <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option> |
| 114 | 114 | <?php if ( 'auto-draft' == $post->post_status ) : ?> |
| 115 | 115 | <option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e('Draft') ?></option> |
| 116 | -<?php else : ?> |
|
| 117 | -<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option> |
|
| 116 | +<?php else { |
|
| 117 | + : ?> |
|
| 118 | +<option<?php selected( $post->post_status, 'draft' ); |
|
| 119 | +} |
|
| 120 | +?> value='draft'><?php _e('Draft') ?></option> |
|
| 118 | 121 | <?php endif; ?> |
| 119 | 122 | </select> |
| 120 | 123 | <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a> |
@@ -236,10 +239,11 @@ discard block |
||
| 236 | 239 | <div id="delete-action"> |
| 237 | 240 | <?php |
| 238 | 241 | if ( current_user_can( "delete_post", $post->ID ) ) { |
| 239 | - if ( !EMPTY_TRASH_DAYS ) |
|
| 240 | - $delete_text = __('Delete Permanently'); |
|
| 241 | - else |
|
| 242 | - $delete_text = __('Move to Trash'); |
|
| 242 | + if ( !EMPTY_TRASH_DAYS ) { |
|
| 243 | + $delete_text = __('Delete Permanently'); |
|
| 244 | + } else { |
|
| 245 | + $delete_text = __('Move to Trash'); |
|
| 246 | + } |
|
| 243 | 247 | ?> |
| 244 | 248 | <a class="submitdelete deletion" href="<?php echo get_delete_post_link($post->ID); ?>"><?php echo $delete_text; ?></a><?php |
| 245 | 249 | } ?> |
@@ -253,13 +257,19 @@ discard block |
||
| 253 | 257 | if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> |
| 254 | 258 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" /> |
| 255 | 259 | <?php submit_button( __( 'Schedule' ), 'primary button-large', 'publish', false ); ?> |
| 256 | -<?php else : ?> |
|
| 260 | +<?php else { |
|
| 261 | + : ?> |
|
| 257 | 262 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" /> |
| 258 | - <?php submit_button( __( 'Publish' ), 'primary button-large', 'publish', false ); ?> |
|
| 263 | + <?php submit_button( __( 'Publish' ), 'primary button-large', 'publish', false ); |
|
| 264 | +} |
|
| 265 | +?> |
|
| 259 | 266 | <?php endif; |
| 260 | - else : ?> |
|
| 267 | + else { |
|
| 268 | + : ?> |
|
| 261 | 269 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" /> |
| 262 | - <?php submit_button( __( 'Submit for Review' ), 'primary button-large', 'publish', false ); ?> |
|
| 270 | + <?php submit_button( __( 'Submit for Review' ), 'primary button-large', 'publish', false ); |
|
| 271 | + } |
|
| 272 | + ?> |
|
| 263 | 273 | <?php |
| 264 | 274 | endif; |
| 265 | 275 | } else { ?> |
@@ -321,9 +331,10 @@ discard block |
||
| 321 | 331 | <div id="major-publishing-actions"> |
| 322 | 332 | <div id="delete-action"> |
| 323 | 333 | <?php |
| 324 | - if ( current_user_can( 'delete_post', $post->ID ) ) |
|
| 325 | - if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { |
|
| 334 | + if ( current_user_can( 'delete_post', $post->ID ) ) { |
|
| 335 | + if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { |
|
| 326 | 336 | echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . _x( 'Trash', 'verb' ) . "</a>"; |
| 337 | + } |
|
| 327 | 338 | } else { |
| 328 | 339 | $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; |
| 329 | 340 | echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "'>" . __( 'Delete Permanently' ) . "</a>"; |
@@ -365,11 +376,13 @@ discard block |
||
| 365 | 376 | |
| 366 | 377 | if ( is_array( $post_formats[0] ) ) : |
| 367 | 378 | $post_format = get_post_format( $post->ID ); |
| 368 | - if ( !$post_format ) |
|
| 369 | - $post_format = '0'; |
|
| 379 | + if ( !$post_format ) { |
|
| 380 | + $post_format = '0'; |
|
| 381 | + } |
|
| 370 | 382 | // Add in the current one if it isn't there yet, in case the current theme doesn't support it |
| 371 | - if ( $post_format && !in_array( $post_format, $post_formats[0] ) ) |
|
| 372 | - $post_formats[0][] = $post_format; |
|
| 383 | + if ( $post_format && !in_array( $post_format, $post_formats[0] ) ) { |
|
| 384 | + $post_formats[0][] = $post_format; |
|
| 385 | + } |
|
| 373 | 386 | ?> |
| 374 | 387 | <div id="post-formats-select"> |
| 375 | 388 | <fieldset> |
@@ -612,9 +625,10 @@ discard block |
||
| 612 | 625 | ); |
| 613 | 626 | ?></p> |
| 614 | 627 | <?php |
| 615 | -if ( ! empty($pings) ) |
|
| 628 | +if ( ! empty($pings) ) { |
|
| 616 | 629 | echo $pings; |
| 617 | 630 | } |
| 631 | +} |
|
| 618 | 632 | |
| 619 | 633 | /** |
| 620 | 634 | * Display custom fields form fields. |
@@ -630,9 +644,10 @@ discard block |
||
| 630 | 644 | <?php |
| 631 | 645 | $metadata = has_meta($post->ID); |
| 632 | 646 | foreach ( $metadata as $key => $value ) { |
| 633 | - if ( is_protected_meta( $metadata[ $key ][ 'meta_key' ], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ][ 'meta_key' ] ) ) |
|
| 634 | - unset( $metadata[ $key ] ); |
|
| 635 | -} |
|
| 647 | + if ( is_protected_meta( $metadata[ $key ][ 'meta_key' ], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ][ 'meta_key' ] ) ) { |
|
| 648 | + unset( $metadata[ $key ] ); |
|
| 649 | + } |
|
| 650 | + } |
|
| 636 | 651 | list_meta( $metadata ); |
| 637 | 652 | meta_form( $post ); ?> |
| 638 | 653 | </div> |
@@ -947,10 +962,11 @@ discard block |
||
| 947 | 962 | <div id="categories-all" class="tabs-panel"> |
| 948 | 963 | <ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear"> |
| 949 | 964 | <?php |
| 950 | - if ( isset($link->link_id) ) |
|
| 951 | - wp_link_category_checklist($link->link_id); |
|
| 952 | - else |
|
| 953 | - wp_link_category_checklist(); |
|
| 965 | + if ( isset($link->link_id) ) { |
|
| 966 | + wp_link_category_checklist($link->link_id); |
|
| 967 | + } else { |
|
| 968 | + wp_link_category_checklist(); |
|
| 969 | + } |
|
| 954 | 970 | ?> |
| 955 | 971 | </ul> |
| 956 | 972 | </div> |
@@ -1012,8 +1028,10 @@ discard block |
||
| 1012 | 1028 | function xfn_check( $class, $value = '', $deprecated = '' ) { |
| 1013 | 1029 | global $link; |
| 1014 | 1030 | |
| 1015 | - if ( !empty( $deprecated ) ) |
|
| 1016 | - _deprecated_argument( __FUNCTION__, '0.0.0' ); // Never implemented |
|
| 1031 | + if ( !empty( $deprecated ) ) { |
|
| 1032 | + _deprecated_argument( __FUNCTION__, '0.0.0' ); |
|
| 1033 | + } |
|
| 1034 | + // Never implemented |
|
| 1017 | 1035 | |
| 1018 | 1036 | $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; |
| 1019 | 1037 | $rels = preg_split('/\s+/', $link_rel); |
@@ -1023,10 +1041,18 @@ discard block |
||
| 1023 | 1041 | } |
| 1024 | 1042 | |
| 1025 | 1043 | if ('' == $value) { |
| 1026 | - if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"'; |
|
| 1027 | - if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"'; |
|
| 1028 | - if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"'; |
|
| 1029 | - if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"'; |
|
| 1044 | + if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) { |
|
| 1045 | + echo ' checked="checked"'; |
|
| 1046 | + } |
|
| 1047 | + if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) { |
|
| 1048 | + echo ' checked="checked"'; |
|
| 1049 | + } |
|
| 1050 | + if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) { |
|
| 1051 | + echo ' checked="checked"'; |
|
| 1052 | + } |
|
| 1053 | + if ('identity' == $class && in_array('me', $rels) ) { |
|
| 1054 | + echo ' checked="checked"'; |
|
| 1055 | + } |
|
| 1030 | 1056 | } |
| 1031 | 1057 | } |
| 1032 | 1058 | |
@@ -1176,8 +1202,9 @@ discard block |
||
| 1176 | 1202 | <?php |
| 1177 | 1203 | for ( $r = 0; $r <= 10; $r++ ) { |
| 1178 | 1204 | echo '<option value="' . $r . '"'; |
| 1179 | - if ( isset($link->link_rating) && $link->link_rating == $r ) |
|
| 1180 | - echo ' selected="selected"'; |
|
| 1205 | + if ( isset($link->link_rating) && $link->link_rating == $r ) { |
|
| 1206 | + echo ' selected="selected"'; |
|
| 1207 | + } |
|
| 1181 | 1208 | echo('>' . $r . '</option>'); |
| 1182 | 1209 | } |
| 1183 | 1210 | ?></select> <?php _e('(Leave at 0 for no rating.)') ?> |
@@ -24,19 +24,19 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @return mixed Comment post ID on success. |
| 26 | 26 | */ |
| 27 | -function comment_exists( $comment_author, $comment_date, $timezone = 'blog' ) { |
|
| 27 | +function comment_exists($comment_author, $comment_date, $timezone = 'blog') { |
|
| 28 | 28 | global $wpdb; |
| 29 | 29 | |
| 30 | 30 | $date_field = 'comment_date'; |
| 31 | - if ( 'gmt' === $timezone ) { |
|
| 31 | + if ('gmt' === $timezone) { |
|
| 32 | 32 | $date_field = 'comment_date_gmt'; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - return $wpdb->get_var( $wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments |
|
| 35 | + return $wpdb->get_var($wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments |
|
| 36 | 36 | WHERE comment_author = %s AND $date_field = %s", |
| 37 | - stripslashes( $comment_author ), |
|
| 38 | - stripslashes( $comment_date ) |
|
| 39 | - ) ); |
|
| 37 | + stripslashes($comment_author), |
|
| 38 | + stripslashes($comment_date) |
|
| 39 | + )); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -45,44 +45,44 @@ discard block |
||
| 45 | 45 | * @since 2.0.0 |
| 46 | 46 | */ |
| 47 | 47 | function edit_comment() { |
| 48 | - if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) |
|
| 49 | - wp_die ( __( 'Sorry, you are not allowed to edit comments on this post.' ) ); |
|
| 48 | + if ( ! current_user_can('edit_comment', (int) $_POST['comment_ID'])) |
|
| 49 | + wp_die(__('Sorry, you are not allowed to edit comments on this post.')); |
|
| 50 | 50 | |
| 51 | - if ( isset( $_POST['newcomment_author'] ) ) |
|
| 51 | + if (isset($_POST['newcomment_author'])) |
|
| 52 | 52 | $_POST['comment_author'] = $_POST['newcomment_author']; |
| 53 | - if ( isset( $_POST['newcomment_author_email'] ) ) |
|
| 53 | + if (isset($_POST['newcomment_author_email'])) |
|
| 54 | 54 | $_POST['comment_author_email'] = $_POST['newcomment_author_email']; |
| 55 | - if ( isset( $_POST['newcomment_author_url'] ) ) |
|
| 55 | + if (isset($_POST['newcomment_author_url'])) |
|
| 56 | 56 | $_POST['comment_author_url'] = $_POST['newcomment_author_url']; |
| 57 | - if ( isset( $_POST['comment_status'] ) ) |
|
| 57 | + if (isset($_POST['comment_status'])) |
|
| 58 | 58 | $_POST['comment_approved'] = $_POST['comment_status']; |
| 59 | - if ( isset( $_POST['content'] ) ) |
|
| 59 | + if (isset($_POST['content'])) |
|
| 60 | 60 | $_POST['comment_content'] = $_POST['content']; |
| 61 | - if ( isset( $_POST['comment_ID'] ) ) |
|
| 61 | + if (isset($_POST['comment_ID'])) |
|
| 62 | 62 | $_POST['comment_ID'] = (int) $_POST['comment_ID']; |
| 63 | 63 | |
| 64 | - foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { |
|
| 65 | - if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { |
|
| 64 | + foreach (array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit) { |
|
| 65 | + if ( ! empty($_POST['hidden_'.$timeunit]) && $_POST['hidden_'.$timeunit] != $_POST[$timeunit]) { |
|
| 66 | 66 | $_POST['edit_date'] = '1'; |
| 67 | 67 | break; |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if ( !empty ( $_POST['edit_date'] ) ) { |
|
| 71 | + if ( ! empty ($_POST['edit_date'])) { |
|
| 72 | 72 | $aa = $_POST['aa']; |
| 73 | 73 | $mm = $_POST['mm']; |
| 74 | 74 | $jj = $_POST['jj']; |
| 75 | 75 | $hh = $_POST['hh']; |
| 76 | 76 | $mn = $_POST['mn']; |
| 77 | 77 | $ss = $_POST['ss']; |
| 78 | - $jj = ($jj > 31 ) ? 31 : $jj; |
|
| 79 | - $hh = ($hh > 23 ) ? $hh -24 : $hh; |
|
| 80 | - $mn = ($mn > 59 ) ? $mn -60 : $mn; |
|
| 81 | - $ss = ($ss > 59 ) ? $ss -60 : $ss; |
|
| 78 | + $jj = ($jj > 31) ? 31 : $jj; |
|
| 79 | + $hh = ($hh > 23) ? $hh - 24 : $hh; |
|
| 80 | + $mn = ($mn > 59) ? $mn - 60 : $mn; |
|
| 81 | + $ss = ($ss > 59) ? $ss - 60 : $ss; |
|
| 82 | 82 | $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - wp_update_comment( $_POST ); |
|
| 85 | + wp_update_comment($_POST); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -93,14 +93,14 @@ discard block |
||
| 93 | 93 | * @param int $id ID of comment to retrieve. |
| 94 | 94 | * @return WP_Comment|false Comment if found. False on failure. |
| 95 | 95 | */ |
| 96 | -function get_comment_to_edit( $id ) { |
|
| 97 | - if ( !$comment = get_comment($id) ) |
|
| 96 | +function get_comment_to_edit($id) { |
|
| 97 | + if ( ! $comment = get_comment($id)) |
|
| 98 | 98 | return false; |
| 99 | 99 | |
| 100 | 100 | $comment->comment_ID = (int) $comment->comment_ID; |
| 101 | 101 | $comment->comment_post_ID = (int) $comment->comment_post_ID; |
| 102 | 102 | |
| 103 | - $comment->comment_content = format_to_edit( $comment->comment_content ); |
|
| 103 | + $comment->comment_content = format_to_edit($comment->comment_content); |
|
| 104 | 104 | /** |
| 105 | 105 | * Filters the comment content before editing. |
| 106 | 106 | * |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @param string $comment->comment_content Comment content. |
| 110 | 110 | */ |
| 111 | - $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content ); |
|
| 111 | + $comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content); |
|
| 112 | 112 | |
| 113 | - $comment->comment_author = format_to_edit( $comment->comment_author ); |
|
| 114 | - $comment->comment_author_email = format_to_edit( $comment->comment_author_email ); |
|
| 115 | - $comment->comment_author_url = format_to_edit( $comment->comment_author_url ); |
|
| 113 | + $comment->comment_author = format_to_edit($comment->comment_author); |
|
| 114 | + $comment->comment_author_email = format_to_edit($comment->comment_author_email); |
|
| 115 | + $comment->comment_author_url = format_to_edit($comment->comment_author_url); |
|
| 116 | 116 | $comment->comment_author_url = esc_url($comment->comment_author_url); |
| 117 | 117 | |
| 118 | 118 | return $comment; |
@@ -128,23 +128,23 @@ discard block |
||
| 128 | 128 | * @param int|array $post_id Either a single Post ID or an array of Post IDs |
| 129 | 129 | * @return int|array Either a single Posts pending comments as an int or an array of ints keyed on the Post IDs |
| 130 | 130 | */ |
| 131 | -function get_pending_comments_num( $post_id ) { |
|
| 131 | +function get_pending_comments_num($post_id) { |
|
| 132 | 132 | global $wpdb; |
| 133 | 133 | |
| 134 | 134 | $single = false; |
| 135 | - if ( !is_array($post_id) ) { |
|
| 135 | + if ( ! is_array($post_id)) { |
|
| 136 | 136 | $post_id_array = (array) $post_id; |
| 137 | 137 | $single = true; |
| 138 | 138 | } else { |
| 139 | 139 | $post_id_array = $post_id; |
| 140 | 140 | } |
| 141 | 141 | $post_id_array = array_map('intval', $post_id_array); |
| 142 | - $post_id_in = "'" . implode("', '", $post_id_array) . "'"; |
|
| 142 | + $post_id_in = "'".implode("', '", $post_id_array)."'"; |
|
| 143 | 143 | |
| 144 | - $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A ); |
|
| 144 | + $pending = $wpdb->get_results("SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A); |
|
| 145 | 145 | |
| 146 | - if ( $single ) { |
|
| 147 | - if ( empty($pending) ) |
|
| 146 | + if ($single) { |
|
| 147 | + if (empty($pending)) |
|
| 148 | 148 | return 0; |
| 149 | 149 | else |
| 150 | 150 | return absint($pending[0]['num_comments']); |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | $pending_keyed = array(); |
| 154 | 154 | |
| 155 | 155 | // Default to zero pending for all posts in request |
| 156 | - foreach ( $post_id_array as $id ) |
|
| 156 | + foreach ($post_id_array as $id) |
|
| 157 | 157 | $pending_keyed[$id] = 0; |
| 158 | 158 | |
| 159 | - if ( !empty($pending) ) |
|
| 160 | - foreach ( $pending as $pend ) |
|
| 159 | + if ( ! empty($pending)) |
|
| 160 | + foreach ($pending as $pend) |
|
| 161 | 161 | $pending_keyed[$pend['comment_post_ID']] = absint($pend['num_comments']); |
| 162 | 162 | |
| 163 | 163 | return $pending_keyed; |
@@ -171,8 +171,8 @@ discard block |
||
| 171 | 171 | * @param string $name User name. |
| 172 | 172 | * @return string Avatar with Admin name. |
| 173 | 173 | */ |
| 174 | -function floated_admin_avatar( $name ) { |
|
| 175 | - $avatar = get_avatar( get_comment(), 32, 'mystery' ); |
|
| 174 | +function floated_admin_avatar($name) { |
|
| 175 | + $avatar = get_avatar(get_comment(), 32, 'mystery'); |
|
| 176 | 176 | return "$avatar $name"; |
| 177 | 177 | } |
| 178 | 178 | |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | * @since 2.7.0 |
| 181 | 181 | */ |
| 182 | 182 | function enqueue_comment_hotkeys_js() { |
| 183 | - if ( 'true' == get_user_option( 'comment_shortcuts' ) ) |
|
| 184 | - wp_enqueue_script( 'jquery-table-hotkeys' ); |
|
| 183 | + if ('true' == get_user_option('comment_shortcuts')) |
|
| 184 | + wp_enqueue_script('jquery-table-hotkeys'); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * @param string $msg Error Message. Assumed to contain HTML and be sanitized. |
| 191 | 191 | */ |
| 192 | -function comment_footer_die( $msg ) { |
|
| 192 | +function comment_footer_die($msg) { |
|
| 193 | 193 | echo "<div class='wrap'><p>$msg</p></div>"; |
| 194 | - include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
| 194 | + include(ABSPATH.'wp-admin/admin-footer.php'); |
|
| 195 | 195 | die; |
| 196 | 196 | } |
| 197 | 197 | \ No newline at end of file |
@@ -45,21 +45,28 @@ discard block |
||
| 45 | 45 | * @since 2.0.0 |
| 46 | 46 | */ |
| 47 | 47 | function edit_comment() { |
| 48 | - if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) |
|
| 49 | - wp_die ( __( 'Sorry, you are not allowed to edit comments on this post.' ) ); |
|
| 50 | - |
|
| 51 | - if ( isset( $_POST['newcomment_author'] ) ) |
|
| 52 | - $_POST['comment_author'] = $_POST['newcomment_author']; |
|
| 53 | - if ( isset( $_POST['newcomment_author_email'] ) ) |
|
| 54 | - $_POST['comment_author_email'] = $_POST['newcomment_author_email']; |
|
| 55 | - if ( isset( $_POST['newcomment_author_url'] ) ) |
|
| 56 | - $_POST['comment_author_url'] = $_POST['newcomment_author_url']; |
|
| 57 | - if ( isset( $_POST['comment_status'] ) ) |
|
| 58 | - $_POST['comment_approved'] = $_POST['comment_status']; |
|
| 59 | - if ( isset( $_POST['content'] ) ) |
|
| 60 | - $_POST['comment_content'] = $_POST['content']; |
|
| 61 | - if ( isset( $_POST['comment_ID'] ) ) |
|
| 62 | - $_POST['comment_ID'] = (int) $_POST['comment_ID']; |
|
| 48 | + if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) { |
|
| 49 | + wp_die ( __( 'Sorry, you are not allowed to edit comments on this post.' ) ); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + if ( isset( $_POST['newcomment_author'] ) ) { |
|
| 53 | + $_POST['comment_author'] = $_POST['newcomment_author']; |
|
| 54 | + } |
|
| 55 | + if ( isset( $_POST['newcomment_author_email'] ) ) { |
|
| 56 | + $_POST['comment_author_email'] = $_POST['newcomment_author_email']; |
|
| 57 | + } |
|
| 58 | + if ( isset( $_POST['newcomment_author_url'] ) ) { |
|
| 59 | + $_POST['comment_author_url'] = $_POST['newcomment_author_url']; |
|
| 60 | + } |
|
| 61 | + if ( isset( $_POST['comment_status'] ) ) { |
|
| 62 | + $_POST['comment_approved'] = $_POST['comment_status']; |
|
| 63 | + } |
|
| 64 | + if ( isset( $_POST['content'] ) ) { |
|
| 65 | + $_POST['comment_content'] = $_POST['content']; |
|
| 66 | + } |
|
| 67 | + if ( isset( $_POST['comment_ID'] ) ) { |
|
| 68 | + $_POST['comment_ID'] = (int) $_POST['comment_ID']; |
|
| 69 | + } |
|
| 63 | 70 | |
| 64 | 71 | foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { |
| 65 | 72 | if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { |
@@ -94,8 +101,9 @@ discard block |
||
| 94 | 101 | * @return WP_Comment|false Comment if found. False on failure. |
| 95 | 102 | */ |
| 96 | 103 | function get_comment_to_edit( $id ) { |
| 97 | - if ( !$comment = get_comment($id) ) |
|
| 98 | - return false; |
|
| 104 | + if ( !$comment = get_comment($id) ) { |
|
| 105 | + return false; |
|
| 106 | + } |
|
| 99 | 107 | |
| 100 | 108 | $comment->comment_ID = (int) $comment->comment_ID; |
| 101 | 109 | $comment->comment_post_ID = (int) $comment->comment_post_ID; |
@@ -144,21 +152,24 @@ discard block |
||
| 144 | 152 | $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A ); |
| 145 | 153 | |
| 146 | 154 | if ( $single ) { |
| 147 | - if ( empty($pending) ) |
|
| 148 | - return 0; |
|
| 149 | - else |
|
| 150 | - return absint($pending[0]['num_comments']); |
|
| 155 | + if ( empty($pending) ) { |
|
| 156 | + return 0; |
|
| 157 | + } else { |
|
| 158 | + return absint($pending[0]['num_comments']); |
|
| 159 | + } |
|
| 151 | 160 | } |
| 152 | 161 | |
| 153 | 162 | $pending_keyed = array(); |
| 154 | 163 | |
| 155 | 164 | // Default to zero pending for all posts in request |
| 156 | - foreach ( $post_id_array as $id ) |
|
| 157 | - $pending_keyed[$id] = 0; |
|
| 165 | + foreach ( $post_id_array as $id ) { |
|
| 166 | + $pending_keyed[$id] = 0; |
|
| 167 | + } |
|
| 158 | 168 | |
| 159 | - if ( !empty($pending) ) |
|
| 160 | - foreach ( $pending as $pend ) |
|
| 169 | + if ( !empty($pending) ) { |
|
| 170 | + foreach ( $pending as $pend ) |
|
| 161 | 171 | $pending_keyed[$pend['comment_post_ID']] = absint($pend['num_comments']); |
| 172 | + } |
|
| 162 | 173 | |
| 163 | 174 | return $pending_keyed; |
| 164 | 175 | } |
@@ -180,9 +191,10 @@ discard block |
||
| 180 | 191 | * @since 2.7.0 |
| 181 | 192 | */ |
| 182 | 193 | function enqueue_comment_hotkeys_js() { |
| 183 | - if ( 'true' == get_user_option( 'comment_shortcuts' ) ) |
|
| 184 | - wp_enqueue_script( 'jquery-table-hotkeys' ); |
|
| 185 | -} |
|
| 194 | + if ( 'true' == get_user_option( 'comment_shortcuts' ) ) { |
|
| 195 | + wp_enqueue_script( 'jquery-table-hotkeys' ); |
|
| 196 | + } |
|
| 197 | + } |
|
| 186 | 198 | |
| 187 | 199 | /** |
| 188 | 200 | * Display error message at bottom of comments. |
@@ -18,157 +18,157 @@ discard block |
||
| 18 | 18 | * @param array $post_data Array of post data. Defaults to the contents of $_POST. |
| 19 | 19 | * @return object|bool WP_Error on failure, true on success. |
| 20 | 20 | */ |
| 21 | -function _wp_translate_postdata( $update = false, $post_data = null ) { |
|
| 21 | +function _wp_translate_postdata($update = false, $post_data = null) { |
|
| 22 | 22 | |
| 23 | - if ( empty($post_data) ) |
|
| 23 | + if (empty($post_data)) |
|
| 24 | 24 | $post_data = &$_POST; |
| 25 | 25 | |
| 26 | - if ( $update ) |
|
| 26 | + if ($update) |
|
| 27 | 27 | $post_data['ID'] = (int) $post_data['post_ID']; |
| 28 | 28 | |
| 29 | - $ptype = get_post_type_object( $post_data['post_type'] ); |
|
| 29 | + $ptype = get_post_type_object($post_data['post_type']); |
|
| 30 | 30 | |
| 31 | - if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) { |
|
| 32 | - if ( 'page' == $post_data['post_type'] ) |
|
| 33 | - return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); |
|
| 31 | + if ($update && ! current_user_can('edit_post', $post_data['ID'])) { |
|
| 32 | + if ('page' == $post_data['post_type']) |
|
| 33 | + return new WP_Error('edit_others_pages', __('Sorry, you are not allowed to edit pages as this user.')); |
|
| 34 | 34 | else |
| 35 | - return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); |
|
| 36 | - } elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) { |
|
| 37 | - if ( 'page' == $post_data['post_type'] ) |
|
| 38 | - return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); |
|
| 35 | + return new WP_Error('edit_others_posts', __('Sorry, you are not allowed to edit posts as this user.')); |
|
| 36 | + } elseif ( ! $update && ! current_user_can($ptype->cap->create_posts)) { |
|
| 37 | + if ('page' == $post_data['post_type']) |
|
| 38 | + return new WP_Error('edit_others_pages', __('Sorry, you are not allowed to create pages as this user.')); |
|
| 39 | 39 | else |
| 40 | - return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); |
|
| 40 | + return new WP_Error('edit_others_posts', __('Sorry, you are not allowed to create posts as this user.')); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if ( isset( $post_data['content'] ) ) |
|
| 43 | + if (isset($post_data['content'])) |
|
| 44 | 44 | $post_data['post_content'] = $post_data['content']; |
| 45 | 45 | |
| 46 | - if ( isset( $post_data['excerpt'] ) ) |
|
| 46 | + if (isset($post_data['excerpt'])) |
|
| 47 | 47 | $post_data['post_excerpt'] = $post_data['excerpt']; |
| 48 | 48 | |
| 49 | - if ( isset( $post_data['parent_id'] ) ) |
|
| 49 | + if (isset($post_data['parent_id'])) |
|
| 50 | 50 | $post_data['post_parent'] = (int) $post_data['parent_id']; |
| 51 | 51 | |
| 52 | - if ( isset($post_data['trackback_url']) ) |
|
| 52 | + if (isset($post_data['trackback_url'])) |
|
| 53 | 53 | $post_data['to_ping'] = $post_data['trackback_url']; |
| 54 | 54 | |
| 55 | 55 | $post_data['user_ID'] = get_current_user_id(); |
| 56 | 56 | |
| 57 | - if (!empty ( $post_data['post_author_override'] ) ) { |
|
| 57 | + if ( ! empty ($post_data['post_author_override'])) { |
|
| 58 | 58 | $post_data['post_author'] = (int) $post_data['post_author_override']; |
| 59 | 59 | } else { |
| 60 | - if (!empty ( $post_data['post_author'] ) ) { |
|
| 60 | + if ( ! empty ($post_data['post_author'])) { |
|
| 61 | 61 | $post_data['post_author'] = (int) $post_data['post_author']; |
| 62 | 62 | } else { |
| 63 | 63 | $post_data['post_author'] = (int) $post_data['user_ID']; |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] ) |
|
| 68 | - && ! current_user_can( $ptype->cap->edit_others_posts ) ) { |
|
| 69 | - if ( $update ) { |
|
| 70 | - if ( 'page' == $post_data['post_type'] ) |
|
| 71 | - return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); |
|
| 67 | + if (isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) |
|
| 68 | + && ! current_user_can($ptype->cap->edit_others_posts)) { |
|
| 69 | + if ($update) { |
|
| 70 | + if ('page' == $post_data['post_type']) |
|
| 71 | + return new WP_Error('edit_others_pages', __('Sorry, you are not allowed to edit pages as this user.')); |
|
| 72 | 72 | else |
| 73 | - return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); |
|
| 73 | + return new WP_Error('edit_others_posts', __('Sorry, you are not allowed to edit posts as this user.')); |
|
| 74 | 74 | } else { |
| 75 | - if ( 'page' == $post_data['post_type'] ) |
|
| 76 | - return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); |
|
| 75 | + if ('page' == $post_data['post_type']) |
|
| 76 | + return new WP_Error('edit_others_pages', __('Sorry, you are not allowed to create pages as this user.')); |
|
| 77 | 77 | else |
| 78 | - return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); |
|
| 78 | + return new WP_Error('edit_others_posts', __('Sorry, you are not allowed to create posts as this user.')); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if ( ! empty( $post_data['post_status'] ) ) { |
|
| 83 | - $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); |
|
| 82 | + if ( ! empty($post_data['post_status'])) { |
|
| 83 | + $post_data['post_status'] = sanitize_key($post_data['post_status']); |
|
| 84 | 84 | |
| 85 | 85 | // No longer an auto-draft |
| 86 | - if ( 'auto-draft' === $post_data['post_status'] ) { |
|
| 86 | + if ('auto-draft' === $post_data['post_status']) { |
|
| 87 | 87 | $post_data['post_status'] = 'draft'; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if ( ! get_post_status_object( $post_data['post_status'] ) ) { |
|
| 91 | - unset( $post_data['post_status'] ); |
|
| 90 | + if ( ! get_post_status_object($post_data['post_status'])) { |
|
| 91 | + unset($post_data['post_status']); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // What to do based on which button they pressed |
| 96 | - if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) |
|
| 96 | + if (isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft']) |
|
| 97 | 97 | $post_data['post_status'] = 'draft'; |
| 98 | - if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) |
|
| 98 | + if (isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate']) |
|
| 99 | 99 | $post_data['post_status'] = 'private'; |
| 100 | - if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) ) |
|
| 100 | + if (isset($post_data['publish']) && ('' != $post_data['publish']) && ( ! isset($post_data['post_status']) || $post_data['post_status'] != 'private')) |
|
| 101 | 101 | $post_data['post_status'] = 'publish'; |
| 102 | - if ( isset($post_data['advanced']) && '' != $post_data['advanced'] ) |
|
| 102 | + if (isset($post_data['advanced']) && '' != $post_data['advanced']) |
|
| 103 | 103 | $post_data['post_status'] = 'draft'; |
| 104 | - if ( isset($post_data['pending']) && '' != $post_data['pending'] ) |
|
| 104 | + if (isset($post_data['pending']) && '' != $post_data['pending']) |
|
| 105 | 105 | $post_data['post_status'] = 'pending'; |
| 106 | 106 | |
| 107 | - if ( isset( $post_data['ID'] ) ) |
|
| 107 | + if (isset($post_data['ID'])) |
|
| 108 | 108 | $post_id = $post_data['ID']; |
| 109 | 109 | else |
| 110 | 110 | $post_id = false; |
| 111 | - $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false; |
|
| 111 | + $previous_status = $post_id ? get_post_field('post_status', $post_id) : false; |
|
| 112 | 112 | |
| 113 | - if ( isset( $post_data['post_status'] ) && 'private' == $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) { |
|
| 113 | + if (isset($post_data['post_status']) && 'private' == $post_data['post_status'] && ! current_user_can($ptype->cap->publish_posts)) { |
|
| 114 | 114 | $post_data['post_status'] = $previous_status ? $previous_status : 'pending'; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $published_statuses = array( 'publish', 'future' ); |
|
| 117 | + $published_statuses = array('publish', 'future'); |
|
| 118 | 118 | |
| 119 | 119 | // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published. |
| 120 | 120 | // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts. |
| 121 | - if ( isset($post_data['post_status']) && (in_array( $post_data['post_status'], $published_statuses ) && !current_user_can( $ptype->cap->publish_posts )) ) |
|
| 122 | - if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) ) |
|
| 121 | + if (isset($post_data['post_status']) && (in_array($post_data['post_status'], $published_statuses) && ! current_user_can($ptype->cap->publish_posts))) |
|
| 122 | + if ( ! in_array($previous_status, $published_statuses) || ! current_user_can('edit_post', $post_id)) |
|
| 123 | 123 | $post_data['post_status'] = 'pending'; |
| 124 | 124 | |
| 125 | - if ( ! isset( $post_data['post_status'] ) ) { |
|
| 125 | + if ( ! isset($post_data['post_status'])) { |
|
| 126 | 126 | $post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - if ( isset( $post_data['post_password'] ) && ! current_user_can( $ptype->cap->publish_posts ) ) { |
|
| 130 | - unset( $post_data['post_password'] ); |
|
| 129 | + if (isset($post_data['post_password']) && ! current_user_can($ptype->cap->publish_posts)) { |
|
| 130 | + unset($post_data['post_password']); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if (!isset( $post_data['comment_status'] )) |
|
| 133 | + if ( ! isset($post_data['comment_status'])) |
|
| 134 | 134 | $post_data['comment_status'] = 'closed'; |
| 135 | 135 | |
| 136 | - if (!isset( $post_data['ping_status'] )) |
|
| 136 | + if ( ! isset($post_data['ping_status'])) |
|
| 137 | 137 | $post_data['ping_status'] = 'closed'; |
| 138 | 138 | |
| 139 | - foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { |
|
| 140 | - if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) { |
|
| 139 | + foreach (array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit) { |
|
| 140 | + if ( ! empty($post_data['hidden_'.$timeunit]) && $post_data['hidden_'.$timeunit] != $post_data[$timeunit]) { |
|
| 141 | 141 | $post_data['edit_date'] = '1'; |
| 142 | 142 | break; |
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - if ( !empty( $post_data['edit_date'] ) ) { |
|
| 146 | + if ( ! empty($post_data['edit_date'])) { |
|
| 147 | 147 | $aa = $post_data['aa']; |
| 148 | 148 | $mm = $post_data['mm']; |
| 149 | 149 | $jj = $post_data['jj']; |
| 150 | 150 | $hh = $post_data['hh']; |
| 151 | 151 | $mn = $post_data['mn']; |
| 152 | 152 | $ss = $post_data['ss']; |
| 153 | - $aa = ($aa <= 0 ) ? date('Y') : $aa; |
|
| 154 | - $mm = ($mm <= 0 ) ? date('n') : $mm; |
|
| 155 | - $jj = ($jj > 31 ) ? 31 : $jj; |
|
| 156 | - $jj = ($jj <= 0 ) ? date('j') : $jj; |
|
| 157 | - $hh = ($hh > 23 ) ? $hh -24 : $hh; |
|
| 158 | - $mn = ($mn > 59 ) ? $mn -60 : $mn; |
|
| 159 | - $ss = ($ss > 59 ) ? $ss -60 : $ss; |
|
| 160 | - $post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); |
|
| 161 | - $valid_date = wp_checkdate( $mm, $jj, $aa, $post_data['post_date'] ); |
|
| 162 | - if ( !$valid_date ) { |
|
| 163 | - return new WP_Error( 'invalid_date', __( 'Whoops, the provided date is invalid.' ) ); |
|
| 153 | + $aa = ($aa <= 0) ? date('Y') : $aa; |
|
| 154 | + $mm = ($mm <= 0) ? date('n') : $mm; |
|
| 155 | + $jj = ($jj > 31) ? 31 : $jj; |
|
| 156 | + $jj = ($jj <= 0) ? date('j') : $jj; |
|
| 157 | + $hh = ($hh > 23) ? $hh - 24 : $hh; |
|
| 158 | + $mn = ($mn > 59) ? $mn - 60 : $mn; |
|
| 159 | + $ss = ($ss > 59) ? $ss - 60 : $ss; |
|
| 160 | + $post_data['post_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss); |
|
| 161 | + $valid_date = wp_checkdate($mm, $jj, $aa, $post_data['post_date']); |
|
| 162 | + if ( ! $valid_date) { |
|
| 163 | + return new WP_Error('invalid_date', __('Whoops, the provided date is invalid.')); |
|
| 164 | 164 | } |
| 165 | - $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] ); |
|
| 165 | + $post_data['post_date_gmt'] = get_gmt_from_date($post_data['post_date']); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if ( isset( $post_data['post_category'] ) ) { |
|
| 169 | - $category_object = get_taxonomy( 'category' ); |
|
| 170 | - if ( ! current_user_can( $category_object->cap->assign_terms ) ) { |
|
| 171 | - unset( $post_data['post_category'] ); |
|
| 168 | + if (isset($post_data['post_category'])) { |
|
| 169 | + $category_object = get_taxonomy('category'); |
|
| 170 | + if ( ! current_user_can($category_object->cap->assign_terms)) { |
|
| 171 | + unset($post_data['post_category']); |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
@@ -185,149 +185,149 @@ discard block |
||
| 185 | 185 | * @param array $post_data Optional. |
| 186 | 186 | * @return int Post ID. |
| 187 | 187 | */ |
| 188 | -function edit_post( $post_data = null ) { |
|
| 188 | +function edit_post($post_data = null) { |
|
| 189 | 189 | global $wpdb; |
| 190 | 190 | |
| 191 | - if ( empty($post_data) ) |
|
| 191 | + if (empty($post_data)) |
|
| 192 | 192 | $post_data = &$_POST; |
| 193 | 193 | |
| 194 | 194 | // Clear out any data in internal vars. |
| 195 | - unset( $post_data['filter'] ); |
|
| 195 | + unset($post_data['filter']); |
|
| 196 | 196 | |
| 197 | 197 | $post_ID = (int) $post_data['post_ID']; |
| 198 | - $post = get_post( $post_ID ); |
|
| 198 | + $post = get_post($post_ID); |
|
| 199 | 199 | $post_data['post_type'] = $post->post_type; |
| 200 | 200 | $post_data['post_mime_type'] = $post->post_mime_type; |
| 201 | 201 | |
| 202 | - if ( ! empty( $post_data['post_status'] ) ) { |
|
| 203 | - $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); |
|
| 202 | + if ( ! empty($post_data['post_status'])) { |
|
| 203 | + $post_data['post_status'] = sanitize_key($post_data['post_status']); |
|
| 204 | 204 | |
| 205 | - if ( 'inherit' == $post_data['post_status'] ) { |
|
| 206 | - unset( $post_data['post_status'] ); |
|
| 205 | + if ('inherit' == $post_data['post_status']) { |
|
| 206 | + unset($post_data['post_status']); |
|
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | $ptype = get_post_type_object($post_data['post_type']); |
| 211 | - if ( !current_user_can( 'edit_post', $post_ID ) ) { |
|
| 212 | - if ( 'page' == $post_data['post_type'] ) |
|
| 213 | - wp_die( __('Sorry, you are not allowed to edit this page.' )); |
|
| 211 | + if ( ! current_user_can('edit_post', $post_ID)) { |
|
| 212 | + if ('page' == $post_data['post_type']) |
|
| 213 | + wp_die(__('Sorry, you are not allowed to edit this page.')); |
|
| 214 | 214 | else |
| 215 | - wp_die( __('Sorry, you are not allowed to edit this post.' )); |
|
| 215 | + wp_die(__('Sorry, you are not allowed to edit this post.')); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if ( post_type_supports( $ptype->name, 'revisions' ) ) { |
|
| 219 | - $revisions = wp_get_post_revisions( $post_ID, array( 'order' => 'ASC', 'posts_per_page' => 1 ) ); |
|
| 220 | - $revision = current( $revisions ); |
|
| 218 | + if (post_type_supports($ptype->name, 'revisions')) { |
|
| 219 | + $revisions = wp_get_post_revisions($post_ID, array('order' => 'ASC', 'posts_per_page' => 1)); |
|
| 220 | + $revision = current($revisions); |
|
| 221 | 221 | |
| 222 | 222 | // Check if the revisions have been upgraded |
| 223 | - if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) |
|
| 224 | - _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); |
|
| 223 | + if ($revisions && _wp_get_post_revision_version($revision) < 1) |
|
| 224 | + _wp_upgrade_revisions_of_post($post, wp_get_post_revisions($post_ID)); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if ( isset($post_data['visibility']) ) { |
|
| 228 | - switch ( $post_data['visibility'] ) { |
|
| 227 | + if (isset($post_data['visibility'])) { |
|
| 228 | + switch ($post_data['visibility']) { |
|
| 229 | 229 | case 'public' : |
| 230 | 230 | $post_data['post_password'] = ''; |
| 231 | 231 | break; |
| 232 | 232 | case 'password' : |
| 233 | - unset( $post_data['sticky'] ); |
|
| 233 | + unset($post_data['sticky']); |
|
| 234 | 234 | break; |
| 235 | 235 | case 'private' : |
| 236 | 236 | $post_data['post_status'] = 'private'; |
| 237 | 237 | $post_data['post_password'] = ''; |
| 238 | - unset( $post_data['sticky'] ); |
|
| 238 | + unset($post_data['sticky']); |
|
| 239 | 239 | break; |
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - $post_data = _wp_translate_postdata( true, $post_data ); |
|
| 244 | - if ( is_wp_error($post_data) ) |
|
| 245 | - wp_die( $post_data->get_error_message() ); |
|
| 243 | + $post_data = _wp_translate_postdata(true, $post_data); |
|
| 244 | + if (is_wp_error($post_data)) |
|
| 245 | + wp_die($post_data->get_error_message()); |
|
| 246 | 246 | |
| 247 | 247 | // Post Formats |
| 248 | - if ( isset( $post_data['post_format'] ) ) |
|
| 249 | - set_post_format( $post_ID, $post_data['post_format'] ); |
|
| 248 | + if (isset($post_data['post_format'])) |
|
| 249 | + set_post_format($post_ID, $post_data['post_format']); |
|
| 250 | 250 | |
| 251 | - $format_meta_urls = array( 'url', 'link_url', 'quote_source_url' ); |
|
| 252 | - foreach ( $format_meta_urls as $format_meta_url ) { |
|
| 253 | - $keyed = '_format_' . $format_meta_url; |
|
| 254 | - if ( isset( $post_data[ $keyed ] ) ) |
|
| 255 | - update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) ); |
|
| 251 | + $format_meta_urls = array('url', 'link_url', 'quote_source_url'); |
|
| 252 | + foreach ($format_meta_urls as $format_meta_url) { |
|
| 253 | + $keyed = '_format_'.$format_meta_url; |
|
| 254 | + if (isset($post_data[$keyed])) |
|
| 255 | + update_post_meta($post_ID, $keyed, wp_slash(esc_url_raw(wp_unslash($post_data[$keyed])))); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - $format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' ); |
|
| 258 | + $format_keys = array('quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed'); |
|
| 259 | 259 | |
| 260 | - foreach ( $format_keys as $key ) { |
|
| 261 | - $keyed = '_format_' . $key; |
|
| 262 | - if ( isset( $post_data[ $keyed ] ) ) { |
|
| 263 | - if ( current_user_can( 'unfiltered_html' ) ) |
|
| 264 | - update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] ); |
|
| 260 | + foreach ($format_keys as $key) { |
|
| 261 | + $keyed = '_format_'.$key; |
|
| 262 | + if (isset($post_data[$keyed])) { |
|
| 263 | + if (current_user_can('unfiltered_html')) |
|
| 264 | + update_post_meta($post_ID, $keyed, $post_data[$keyed]); |
|
| 265 | 265 | else |
| 266 | - update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) ); |
|
| 266 | + update_post_meta($post_ID, $keyed, wp_filter_post_kses($post_data[$keyed])); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) { |
|
| 271 | - $id3data = wp_get_attachment_metadata( $post_ID ); |
|
| 272 | - if ( ! is_array( $id3data ) ) { |
|
| 270 | + if ('attachment' === $post_data['post_type'] && preg_match('#^(audio|video)/#', $post_data['post_mime_type'])) { |
|
| 271 | + $id3data = wp_get_attachment_metadata($post_ID); |
|
| 272 | + if ( ! is_array($id3data)) { |
|
| 273 | 273 | $id3data = array(); |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) { |
|
| 277 | - if ( isset( $post_data[ 'id3_' . $key ] ) ) { |
|
| 278 | - $id3data[ $key ] = sanitize_text_field( wp_unslash( $post_data[ 'id3_' . $key ] ) ); |
|
| 276 | + foreach (wp_get_attachment_id3_keys($post, 'edit') as $key => $label) { |
|
| 277 | + if (isset($post_data['id3_'.$key])) { |
|
| 278 | + $id3data[$key] = sanitize_text_field(wp_unslash($post_data['id3_'.$key])); |
|
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | - wp_update_attachment_metadata( $post_ID, $id3data ); |
|
| 281 | + wp_update_attachment_metadata($post_ID, $id3data); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | // Meta Stuff |
| 285 | - if ( isset($post_data['meta']) && $post_data['meta'] ) { |
|
| 286 | - foreach ( $post_data['meta'] as $key => $value ) { |
|
| 287 | - if ( !$meta = get_post_meta_by_id( $key ) ) |
|
| 285 | + if (isset($post_data['meta']) && $post_data['meta']) { |
|
| 286 | + foreach ($post_data['meta'] as $key => $value) { |
|
| 287 | + if ( ! $meta = get_post_meta_by_id($key)) |
|
| 288 | 288 | continue; |
| 289 | - if ( $meta->post_id != $post_ID ) |
|
| 289 | + if ($meta->post_id != $post_ID) |
|
| 290 | 290 | continue; |
| 291 | - if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) |
|
| 291 | + if (is_protected_meta($value['key'], 'post') || ! current_user_can('edit_post_meta', $post_ID, $value['key'])) |
|
| 292 | 292 | continue; |
| 293 | - update_meta( $key, $value['key'], $value['value'] ); |
|
| 293 | + update_meta($key, $value['key'], $value['value']); |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) { |
|
| 298 | - foreach ( $post_data['deletemeta'] as $key => $value ) { |
|
| 299 | - if ( !$meta = get_post_meta_by_id( $key ) ) |
|
| 297 | + if (isset($post_data['deletemeta']) && $post_data['deletemeta']) { |
|
| 298 | + foreach ($post_data['deletemeta'] as $key => $value) { |
|
| 299 | + if ( ! $meta = get_post_meta_by_id($key)) |
|
| 300 | 300 | continue; |
| 301 | - if ( $meta->post_id != $post_ID ) |
|
| 301 | + if ($meta->post_id != $post_ID) |
|
| 302 | 302 | continue; |
| 303 | - if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) |
|
| 303 | + if (is_protected_meta($meta->meta_key, 'post') || ! current_user_can('delete_post_meta', $post_ID, $meta->meta_key)) |
|
| 304 | 304 | continue; |
| 305 | - delete_meta( $key ); |
|
| 305 | + delete_meta($key); |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | // Attachment stuff |
| 310 | - if ( 'attachment' == $post_data['post_type'] ) { |
|
| 311 | - if ( isset( $post_data[ '_wp_attachment_image_alt' ] ) ) { |
|
| 312 | - $image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] ); |
|
| 313 | - if ( $image_alt != get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) ) { |
|
| 314 | - $image_alt = wp_strip_all_tags( $image_alt, true ); |
|
| 310 | + if ('attachment' == $post_data['post_type']) { |
|
| 311 | + if (isset($post_data['_wp_attachment_image_alt'])) { |
|
| 312 | + $image_alt = wp_unslash($post_data['_wp_attachment_image_alt']); |
|
| 313 | + if ($image_alt != get_post_meta($post_ID, '_wp_attachment_image_alt', true)) { |
|
| 314 | + $image_alt = wp_strip_all_tags($image_alt, true); |
|
| 315 | 315 | // update_meta expects slashed. |
| 316 | - update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) ); |
|
| 316 | + update_post_meta($post_ID, '_wp_attachment_image_alt', wp_slash($image_alt)); |
|
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - $attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array(); |
|
| 320 | + $attachment_data = isset($post_data['attachments'][$post_ID]) ? $post_data['attachments'][$post_ID] : array(); |
|
| 321 | 321 | |
| 322 | 322 | /** This filter is documented in wp-admin/includes/media.php */ |
| 323 | - $post_data = apply_filters( 'attachment_fields_to_save', $post_data, $attachment_data ); |
|
| 323 | + $post_data = apply_filters('attachment_fields_to_save', $post_data, $attachment_data); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | // Convert taxonomy input to term IDs, to avoid ambiguity. |
| 327 | - if ( isset( $post_data['tax_input'] ) ) { |
|
| 328 | - foreach ( (array) $post_data['tax_input'] as $taxonomy => $terms ) { |
|
| 327 | + if (isset($post_data['tax_input'])) { |
|
| 328 | + foreach ((array) $post_data['tax_input'] as $taxonomy => $terms) { |
|
| 329 | 329 | // Hierarchical taxonomy data is already sent as term IDs, so no conversion is necessary. |
| 330 | - if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
|
| 330 | + if (is_taxonomy_hierarchical($taxonomy)) { |
|
| 331 | 331 | continue; |
| 332 | 332 | } |
| 333 | 333 | |
@@ -336,67 +336,67 @@ discard block |
||
| 336 | 336 | * Some languages may use a character other than a comma as a delimiter, so we standardize on |
| 337 | 337 | * commas before parsing the list. |
| 338 | 338 | */ |
| 339 | - if ( ! is_array( $terms ) ) { |
|
| 340 | - $comma = _x( ',', 'tag delimiter' ); |
|
| 341 | - if ( ',' !== $comma ) { |
|
| 342 | - $terms = str_replace( $comma, ',', $terms ); |
|
| 339 | + if ( ! is_array($terms)) { |
|
| 340 | + $comma = _x(',', 'tag delimiter'); |
|
| 341 | + if (',' !== $comma) { |
|
| 342 | + $terms = str_replace($comma, ',', $terms); |
|
| 343 | 343 | } |
| 344 | - $terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); |
|
| 344 | + $terms = explode(',', trim($terms, " \n\t\r\0\x0B,")); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | $clean_terms = array(); |
| 348 | - foreach ( $terms as $term ) { |
|
| 348 | + foreach ($terms as $term) { |
|
| 349 | 349 | // Empty terms are invalid input. |
| 350 | - if ( empty( $term ) ) { |
|
| 350 | + if (empty($term)) { |
|
| 351 | 351 | continue; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - $_term = get_terms( $taxonomy, array( |
|
| 354 | + $_term = get_terms($taxonomy, array( |
|
| 355 | 355 | 'name' => $term, |
| 356 | 356 | 'fields' => 'ids', |
| 357 | 357 | 'hide_empty' => false, |
| 358 | - ) ); |
|
| 358 | + )); |
|
| 359 | 359 | |
| 360 | - if ( ! empty( $_term ) ) { |
|
| 361 | - $clean_terms[] = intval( $_term[0] ); |
|
| 360 | + if ( ! empty($_term)) { |
|
| 361 | + $clean_terms[] = intval($_term[0]); |
|
| 362 | 362 | } else { |
| 363 | 363 | // No existing term was found, so pass the string. A new term will be created. |
| 364 | 364 | $clean_terms[] = $term; |
| 365 | 365 | } |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - $post_data['tax_input'][ $taxonomy ] = $clean_terms; |
|
| 368 | + $post_data['tax_input'][$taxonomy] = $clean_terms; |
|
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - add_meta( $post_ID ); |
|
| 372 | + add_meta($post_ID); |
|
| 373 | 373 | |
| 374 | - update_post_meta( $post_ID, '_edit_last', get_current_user_id() ); |
|
| 374 | + update_post_meta($post_ID, '_edit_last', get_current_user_id()); |
|
| 375 | 375 | |
| 376 | - $success = wp_update_post( $post_data ); |
|
| 376 | + $success = wp_update_post($post_data); |
|
| 377 | 377 | // If the save failed, see if we can sanity check the main fields and try again |
| 378 | - if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) { |
|
| 379 | - $fields = array( 'post_title', 'post_content', 'post_excerpt' ); |
|
| 378 | + if ( ! $success && is_callable(array($wpdb, 'strip_invalid_text_for_column'))) { |
|
| 379 | + $fields = array('post_title', 'post_content', 'post_excerpt'); |
|
| 380 | 380 | |
| 381 | - foreach ( $fields as $field ) { |
|
| 382 | - if ( isset( $post_data[ $field ] ) ) { |
|
| 383 | - $post_data[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->posts, $field, $post_data[ $field ] ); |
|
| 381 | + foreach ($fields as $field) { |
|
| 382 | + if (isset($post_data[$field])) { |
|
| 383 | + $post_data[$field] = $wpdb->strip_invalid_text_for_column($wpdb->posts, $field, $post_data[$field]); |
|
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - wp_update_post( $post_data ); |
|
| 387 | + wp_update_post($post_data); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | // Now that we have an ID we can fix any attachment anchor hrefs |
| 391 | - _fix_attachment_links( $post_ID ); |
|
| 391 | + _fix_attachment_links($post_ID); |
|
| 392 | 392 | |
| 393 | - wp_set_post_lock( $post_ID ); |
|
| 393 | + wp_set_post_lock($post_ID); |
|
| 394 | 394 | |
| 395 | - if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) { |
|
| 396 | - if ( ! empty( $post_data['sticky'] ) ) |
|
| 397 | - stick_post( $post_ID ); |
|
| 395 | + if (current_user_can($ptype->cap->edit_others_posts) && current_user_can($ptype->cap->publish_posts)) { |
|
| 396 | + if ( ! empty($post_data['sticky'])) |
|
| 397 | + stick_post($post_ID); |
|
| 398 | 398 | else |
| 399 | - unstick_post( $post_ID ); |
|
| 399 | + unstick_post($post_ID); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | return $post_ID; |
@@ -415,22 +415,22 @@ discard block |
||
| 415 | 415 | * @param array $post_data Optional, the array of post data to process if not provided will use $_POST superglobal. |
| 416 | 416 | * @return array |
| 417 | 417 | */ |
| 418 | -function bulk_edit_posts( $post_data = null ) { |
|
| 418 | +function bulk_edit_posts($post_data = null) { |
|
| 419 | 419 | global $wpdb; |
| 420 | 420 | |
| 421 | - if ( empty($post_data) ) |
|
| 421 | + if (empty($post_data)) |
|
| 422 | 422 | $post_data = &$_POST; |
| 423 | 423 | |
| 424 | - if ( isset($post_data['post_type']) ) |
|
| 424 | + if (isset($post_data['post_type'])) |
|
| 425 | 425 | $ptype = get_post_type_object($post_data['post_type']); |
| 426 | 426 | else |
| 427 | 427 | $ptype = get_post_type_object('post'); |
| 428 | 428 | |
| 429 | - if ( !current_user_can( $ptype->cap->edit_posts ) ) { |
|
| 430 | - if ( 'page' == $ptype->name ) |
|
| 431 | - wp_die( __('Sorry, you are not allowed to edit pages.')); |
|
| 429 | + if ( ! current_user_can($ptype->cap->edit_posts)) { |
|
| 430 | + if ('page' == $ptype->name) |
|
| 431 | + wp_die(__('Sorry, you are not allowed to edit pages.')); |
|
| 432 | 432 | else |
| 433 | - wp_die( __('Sorry, you are not allowed to edit posts.')); |
|
| 433 | + wp_die(__('Sorry, you are not allowed to edit posts.')); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | if ( -1 == $post_data['_status'] ) { |
@@ -441,15 +441,15 @@ discard block |
||
| 441 | 441 | } |
| 442 | 442 | unset($post_data['_status']); |
| 443 | 443 | |
| 444 | - if ( ! empty( $post_data['post_status'] ) ) { |
|
| 445 | - $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); |
|
| 444 | + if ( ! empty($post_data['post_status'])) { |
|
| 445 | + $post_data['post_status'] = sanitize_key($post_data['post_status']); |
|
| 446 | 446 | |
| 447 | - if ( 'inherit' == $post_data['post_status'] ) { |
|
| 448 | - unset( $post_data['post_status'] ); |
|
| 447 | + if ('inherit' == $post_data['post_status']) { |
|
| 448 | + unset($post_data['post_status']); |
|
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - $post_IDs = array_map( 'intval', (array) $post_data['post'] ); |
|
| 452 | + $post_IDs = array_map('intval', (array) $post_data['post']); |
|
| 453 | 453 | |
| 454 | 454 | $reset = array( |
| 455 | 455 | 'post_author', 'post_status', 'post_password', |
@@ -458,43 +458,43 @@ discard block |
||
| 458 | 458 | 'post_category', 'sticky', 'post_format', |
| 459 | 459 | ); |
| 460 | 460 | |
| 461 | - foreach ( $reset as $field ) { |
|
| 462 | - if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) |
|
| 461 | + foreach ($reset as $field) { |
|
| 462 | + if (isset($post_data[$field]) && ('' == $post_data[$field] || -1 == $post_data[$field])) |
|
| 463 | 463 | unset($post_data[$field]); |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - if ( isset($post_data['post_category']) ) { |
|
| 467 | - if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) ) |
|
| 468 | - $new_cats = array_map( 'absint', $post_data['post_category'] ); |
|
| 466 | + if (isset($post_data['post_category'])) { |
|
| 467 | + if (is_array($post_data['post_category']) && ! empty($post_data['post_category'])) |
|
| 468 | + $new_cats = array_map('absint', $post_data['post_category']); |
|
| 469 | 469 | else |
| 470 | 470 | unset($post_data['post_category']); |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | $tax_input = array(); |
| 474 | - if ( isset($post_data['tax_input'])) { |
|
| 475 | - foreach ( $post_data['tax_input'] as $tax_name => $terms ) { |
|
| 476 | - if ( empty($terms) ) |
|
| 474 | + if (isset($post_data['tax_input'])) { |
|
| 475 | + foreach ($post_data['tax_input'] as $tax_name => $terms) { |
|
| 476 | + if (empty($terms)) |
|
| 477 | 477 | continue; |
| 478 | - if ( is_taxonomy_hierarchical( $tax_name ) ) { |
|
| 479 | - $tax_input[ $tax_name ] = array_map( 'absint', $terms ); |
|
| 478 | + if (is_taxonomy_hierarchical($tax_name)) { |
|
| 479 | + $tax_input[$tax_name] = array_map('absint', $terms); |
|
| 480 | 480 | } else { |
| 481 | - $comma = _x( ',', 'tag delimiter' ); |
|
| 482 | - if ( ',' !== $comma ) |
|
| 483 | - $terms = str_replace( $comma, ',', $terms ); |
|
| 484 | - $tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); |
|
| 481 | + $comma = _x(',', 'tag delimiter'); |
|
| 482 | + if (',' !== $comma) |
|
| 483 | + $terms = str_replace($comma, ',', $terms); |
|
| 484 | + $tax_input[$tax_name] = explode(',', trim($terms, " \n\t\r\0\x0B,")); |
|
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - if ( isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent']) ) { |
|
| 489 | + if (isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent'])) { |
|
| 490 | 490 | $pages = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'"); |
| 491 | 491 | $children = array(); |
| 492 | 492 | |
| 493 | - for ( $i = 0; $i < 50 && $parent > 0; $i++ ) { |
|
| 493 | + for ($i = 0; $i < 50 && $parent > 0; $i++) { |
|
| 494 | 494 | $children[] = $parent; |
| 495 | 495 | |
| 496 | - foreach ( $pages as $page ) { |
|
| 497 | - if ( $page->ID == $parent ) { |
|
| 496 | + foreach ($pages as $page) { |
|
| 497 | + if ($page->ID == $parent) { |
|
| 498 | 498 | $parent = $page->post_parent; |
| 499 | 499 | break; |
| 500 | 500 | } |
@@ -505,78 +505,78 @@ discard block |
||
| 505 | 505 | $updated = $skipped = $locked = array(); |
| 506 | 506 | $shared_post_data = $post_data; |
| 507 | 507 | |
| 508 | - foreach ( $post_IDs as $post_ID ) { |
|
| 508 | + foreach ($post_IDs as $post_ID) { |
|
| 509 | 509 | // Start with fresh post data with each iteration. |
| 510 | 510 | $post_data = $shared_post_data; |
| 511 | 511 | |
| 512 | - $post_type_object = get_post_type_object( get_post_type( $post_ID ) ); |
|
| 512 | + $post_type_object = get_post_type_object(get_post_type($post_ID)); |
|
| 513 | 513 | |
| 514 | - if ( !isset( $post_type_object ) || ( isset($children) && in_array($post_ID, $children) ) || !current_user_can( 'edit_post', $post_ID ) ) { |
|
| 514 | + if ( ! isset($post_type_object) || (isset($children) && in_array($post_ID, $children)) || ! current_user_can('edit_post', $post_ID)) { |
|
| 515 | 515 | $skipped[] = $post_ID; |
| 516 | 516 | continue; |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - if ( wp_check_post_lock( $post_ID ) ) { |
|
| 519 | + if (wp_check_post_lock($post_ID)) { |
|
| 520 | 520 | $locked[] = $post_ID; |
| 521 | 521 | continue; |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | - $post = get_post( $post_ID ); |
|
| 525 | - $tax_names = get_object_taxonomies( $post ); |
|
| 526 | - foreach ( $tax_names as $tax_name ) { |
|
| 524 | + $post = get_post($post_ID); |
|
| 525 | + $tax_names = get_object_taxonomies($post); |
|
| 526 | + foreach ($tax_names as $tax_name) { |
|
| 527 | 527 | $taxonomy_obj = get_taxonomy($tax_name); |
| 528 | - if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) |
|
| 528 | + if (isset($tax_input[$tax_name]) && current_user_can($taxonomy_obj->cap->assign_terms)) |
|
| 529 | 529 | $new_terms = $tax_input[$tax_name]; |
| 530 | 530 | else |
| 531 | 531 | $new_terms = array(); |
| 532 | 532 | |
| 533 | - if ( $taxonomy_obj->hierarchical ) |
|
| 534 | - $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') ); |
|
| 533 | + if ($taxonomy_obj->hierarchical) |
|
| 534 | + $current_terms = (array) wp_get_object_terms($post_ID, $tax_name, array('fields' => 'ids')); |
|
| 535 | 535 | else |
| 536 | - $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') ); |
|
| 536 | + $current_terms = (array) wp_get_object_terms($post_ID, $tax_name, array('fields' => 'names')); |
|
| 537 | 537 | |
| 538 | - $post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms ); |
|
| 538 | + $post_data['tax_input'][$tax_name] = array_merge($current_terms, $new_terms); |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | - if ( isset($new_cats) && in_array( 'category', $tax_names ) ) { |
|
| 541 | + if (isset($new_cats) && in_array('category', $tax_names)) { |
|
| 542 | 542 | $cats = (array) wp_get_post_categories($post_ID); |
| 543 | - $post_data['post_category'] = array_unique( array_merge($cats, $new_cats) ); |
|
| 544 | - unset( $post_data['tax_input']['category'] ); |
|
| 543 | + $post_data['post_category'] = array_unique(array_merge($cats, $new_cats)); |
|
| 544 | + unset($post_data['tax_input']['category']); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | $post_data['post_type'] = $post->post_type; |
| 548 | 548 | $post_data['post_mime_type'] = $post->post_mime_type; |
| 549 | 549 | $post_data['guid'] = $post->guid; |
| 550 | 550 | |
| 551 | - foreach ( array( 'comment_status', 'ping_status', 'post_author' ) as $field ) { |
|
| 552 | - if ( ! isset( $post_data[ $field ] ) ) { |
|
| 553 | - $post_data[ $field ] = $post->$field; |
|
| 551 | + foreach (array('comment_status', 'ping_status', 'post_author') as $field) { |
|
| 552 | + if ( ! isset($post_data[$field])) { |
|
| 553 | + $post_data[$field] = $post->$field; |
|
| 554 | 554 | } |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | $post_data['ID'] = $post_ID; |
| 558 | 558 | $post_data['post_ID'] = $post_ID; |
| 559 | 559 | |
| 560 | - $post_data = _wp_translate_postdata( true, $post_data ); |
|
| 561 | - if ( is_wp_error( $post_data ) ) { |
|
| 560 | + $post_data = _wp_translate_postdata(true, $post_data); |
|
| 561 | + if (is_wp_error($post_data)) { |
|
| 562 | 562 | $skipped[] = $post_ID; |
| 563 | 563 | continue; |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | - $updated[] = wp_update_post( $post_data ); |
|
| 566 | + $updated[] = wp_update_post($post_data); |
|
| 567 | 567 | |
| 568 | - if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) { |
|
| 569 | - if ( 'sticky' == $post_data['sticky'] ) |
|
| 570 | - stick_post( $post_ID ); |
|
| 568 | + if (isset($post_data['sticky']) && current_user_can($ptype->cap->edit_others_posts)) { |
|
| 569 | + if ('sticky' == $post_data['sticky']) |
|
| 570 | + stick_post($post_ID); |
|
| 571 | 571 | else |
| 572 | - unstick_post( $post_ID ); |
|
| 572 | + unstick_post($post_ID); |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - if ( isset( $post_data['post_format'] ) ) |
|
| 576 | - set_post_format( $post_ID, $post_data['post_format'] ); |
|
| 575 | + if (isset($post_data['post_format'])) |
|
| 576 | + set_post_format($post_ID, $post_data['post_format']); |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked ); |
|
| 579 | + return array('updated' => $updated, 'skipped' => $skipped, 'locked' => $locked); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | /** |
@@ -588,24 +588,24 @@ discard block |
||
| 588 | 588 | * @param bool $create_in_db Optional. Whether to insert the post into database. Default false. |
| 589 | 589 | * @return WP_Post Post object containing all the default post data as attributes |
| 590 | 590 | */ |
| 591 | -function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { |
|
| 591 | +function get_default_post_to_edit($post_type = 'post', $create_in_db = false) { |
|
| 592 | 592 | $post_title = ''; |
| 593 | - if ( !empty( $_REQUEST['post_title'] ) ) |
|
| 594 | - $post_title = esc_html( wp_unslash( $_REQUEST['post_title'] )); |
|
| 593 | + if ( ! empty($_REQUEST['post_title'])) |
|
| 594 | + $post_title = esc_html(wp_unslash($_REQUEST['post_title'])); |
|
| 595 | 595 | |
| 596 | 596 | $post_content = ''; |
| 597 | - if ( !empty( $_REQUEST['content'] ) ) |
|
| 598 | - $post_content = esc_html( wp_unslash( $_REQUEST['content'] )); |
|
| 597 | + if ( ! empty($_REQUEST['content'])) |
|
| 598 | + $post_content = esc_html(wp_unslash($_REQUEST['content'])); |
|
| 599 | 599 | |
| 600 | 600 | $post_excerpt = ''; |
| 601 | - if ( !empty( $_REQUEST['excerpt'] ) ) |
|
| 602 | - $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] )); |
|
| 603 | - |
|
| 604 | - if ( $create_in_db ) { |
|
| 605 | - $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); |
|
| 606 | - $post = get_post( $post_id ); |
|
| 607 | - if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) |
|
| 608 | - set_post_format( $post, get_option( 'default_post_format' ) ); |
|
| 601 | + if ( ! empty($_REQUEST['excerpt'])) |
|
| 602 | + $post_excerpt = esc_html(wp_unslash($_REQUEST['excerpt'])); |
|
| 603 | + |
|
| 604 | + if ($create_in_db) { |
|
| 605 | + $post_id = wp_insert_post(array('post_title' => __('Auto Draft'), 'post_type' => $post_type, 'post_status' => 'auto-draft')); |
|
| 606 | + $post = get_post($post_id); |
|
| 607 | + if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats') && get_option('default_post_format')) |
|
| 608 | + set_post_format($post, get_option('default_post_format')); |
|
| 609 | 609 | } else { |
| 610 | 610 | $post = new stdClass; |
| 611 | 611 | $post->ID = 0; |
@@ -618,14 +618,14 @@ discard block |
||
| 618 | 618 | $post->post_status = 'draft'; |
| 619 | 619 | $post->to_ping = ''; |
| 620 | 620 | $post->pinged = ''; |
| 621 | - $post->comment_status = get_default_comment_status( $post_type ); |
|
| 622 | - $post->ping_status = get_default_comment_status( $post_type, 'pingback' ); |
|
| 623 | - $post->post_pingback = get_option( 'default_pingback_flag' ); |
|
| 624 | - $post->post_category = get_option( 'default_category' ); |
|
| 621 | + $post->comment_status = get_default_comment_status($post_type); |
|
| 622 | + $post->ping_status = get_default_comment_status($post_type, 'pingback'); |
|
| 623 | + $post->post_pingback = get_option('default_pingback_flag'); |
|
| 624 | + $post->post_category = get_option('default_category'); |
|
| 625 | 625 | $post->page_template = 'default'; |
| 626 | 626 | $post->post_parent = 0; |
| 627 | 627 | $post->menu_order = 0; |
| 628 | - $post = new WP_Post( $post ); |
|
| 628 | + $post = new WP_Post($post); |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | /** |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | * @param string $post_content Default post content. |
| 637 | 637 | * @param WP_Post $post Post object. |
| 638 | 638 | */ |
| 639 | - $post->post_content = apply_filters( 'default_content', $post_content, $post ); |
|
| 639 | + $post->post_content = apply_filters('default_content', $post_content, $post); |
|
| 640 | 640 | |
| 641 | 641 | /** |
| 642 | 642 | * Filters the default post title initially used in the "Write Post" form. |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | * @param string $post_title Default post title. |
| 647 | 647 | * @param WP_Post $post Post object. |
| 648 | 648 | */ |
| 649 | - $post->post_title = apply_filters( 'default_title', $post_title, $post ); |
|
| 649 | + $post->post_title = apply_filters('default_title', $post_title, $post); |
|
| 650 | 650 | |
| 651 | 651 | /** |
| 652 | 652 | * Filters the default post excerpt initially used in the "Write Post" form. |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | * @param string $post_excerpt Default post excerpt. |
| 657 | 657 | * @param WP_Post $post Post object. |
| 658 | 658 | */ |
| 659 | - $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post ); |
|
| 659 | + $post->post_excerpt = apply_filters('default_excerpt', $post_excerpt, $post); |
|
| 660 | 660 | |
| 661 | 661 | return $post; |
| 662 | 662 | } |
@@ -676,30 +676,30 @@ discard block |
||
| 676 | 676 | function post_exists($title, $content = '', $date = '') { |
| 677 | 677 | global $wpdb; |
| 678 | 678 | |
| 679 | - $post_title = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) ); |
|
| 680 | - $post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) ); |
|
| 681 | - $post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) ); |
|
| 679 | + $post_title = wp_unslash(sanitize_post_field('post_title', $title, 0, 'db')); |
|
| 680 | + $post_content = wp_unslash(sanitize_post_field('post_content', $content, 0, 'db')); |
|
| 681 | + $post_date = wp_unslash(sanitize_post_field('post_date', $date, 0, 'db')); |
|
| 682 | 682 | |
| 683 | 683 | $query = "SELECT ID FROM $wpdb->posts WHERE 1=1"; |
| 684 | 684 | $args = array(); |
| 685 | 685 | |
| 686 | - if ( !empty ( $date ) ) { |
|
| 686 | + if ( ! empty ($date)) { |
|
| 687 | 687 | $query .= ' AND post_date = %s'; |
| 688 | 688 | $args[] = $post_date; |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - if ( !empty ( $title ) ) { |
|
| 691 | + if ( ! empty ($title)) { |
|
| 692 | 692 | $query .= ' AND post_title = %s'; |
| 693 | 693 | $args[] = $post_title; |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | - if ( !empty ( $content ) ) { |
|
| 696 | + if ( ! empty ($content)) { |
|
| 697 | 697 | $query .= ' AND post_content = %s'; |
| 698 | 698 | $args[] = $post_content; |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - if ( !empty ( $args ) ) |
|
| 702 | - return (int) $wpdb->get_var( $wpdb->prepare($query, $args) ); |
|
| 701 | + if ( ! empty ($args)) |
|
| 702 | + return (int) $wpdb->get_var($wpdb->prepare($query, $args)); |
|
| 703 | 703 | |
| 704 | 704 | return 0; |
| 705 | 705 | } |
@@ -714,63 +714,63 @@ discard block |
||
| 714 | 714 | * @return int|WP_Error |
| 715 | 715 | */ |
| 716 | 716 | function wp_write_post() { |
| 717 | - if ( isset($_POST['post_type']) ) |
|
| 717 | + if (isset($_POST['post_type'])) |
|
| 718 | 718 | $ptype = get_post_type_object($_POST['post_type']); |
| 719 | 719 | else |
| 720 | 720 | $ptype = get_post_type_object('post'); |
| 721 | 721 | |
| 722 | - if ( !current_user_can( $ptype->cap->edit_posts ) ) { |
|
| 723 | - if ( 'page' == $ptype->name ) |
|
| 724 | - return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) ); |
|
| 722 | + if ( ! current_user_can($ptype->cap->edit_posts)) { |
|
| 723 | + if ('page' == $ptype->name) |
|
| 724 | + return new WP_Error('edit_pages', __('Sorry, you are not allowed to create pages on this site.')); |
|
| 725 | 725 | else |
| 726 | - return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to create posts or drafts on this site.' ) ); |
|
| 726 | + return new WP_Error('edit_posts', __('Sorry, you are not allowed to create posts or drafts on this site.')); |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | $_POST['post_mime_type'] = ''; |
| 730 | 730 | |
| 731 | 731 | // Clear out any data in internal vars. |
| 732 | - unset( $_POST['filter'] ); |
|
| 732 | + unset($_POST['filter']); |
|
| 733 | 733 | |
| 734 | 734 | // Edit don't write if we have a post id. |
| 735 | - if ( isset( $_POST['post_ID'] ) ) |
|
| 735 | + if (isset($_POST['post_ID'])) |
|
| 736 | 736 | return edit_post(); |
| 737 | 737 | |
| 738 | - if ( isset($_POST['visibility']) ) { |
|
| 739 | - switch ( $_POST['visibility'] ) { |
|
| 738 | + if (isset($_POST['visibility'])) { |
|
| 739 | + switch ($_POST['visibility']) { |
|
| 740 | 740 | case 'public' : |
| 741 | 741 | $_POST['post_password'] = ''; |
| 742 | 742 | break; |
| 743 | 743 | case 'password' : |
| 744 | - unset( $_POST['sticky'] ); |
|
| 744 | + unset($_POST['sticky']); |
|
| 745 | 745 | break; |
| 746 | 746 | case 'private' : |
| 747 | 747 | $_POST['post_status'] = 'private'; |
| 748 | 748 | $_POST['post_password'] = ''; |
| 749 | - unset( $_POST['sticky'] ); |
|
| 749 | + unset($_POST['sticky']); |
|
| 750 | 750 | break; |
| 751 | 751 | } |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | - $translated = _wp_translate_postdata( false ); |
|
| 755 | - if ( is_wp_error($translated) ) |
|
| 754 | + $translated = _wp_translate_postdata(false); |
|
| 755 | + if (is_wp_error($translated)) |
|
| 756 | 756 | return $translated; |
| 757 | 757 | |
| 758 | 758 | // Create the post. |
| 759 | - $post_ID = wp_insert_post( $_POST ); |
|
| 760 | - if ( is_wp_error( $post_ID ) ) |
|
| 759 | + $post_ID = wp_insert_post($_POST); |
|
| 760 | + if (is_wp_error($post_ID)) |
|
| 761 | 761 | return $post_ID; |
| 762 | 762 | |
| 763 | - if ( empty($post_ID) ) |
|
| 763 | + if (empty($post_ID)) |
|
| 764 | 764 | return 0; |
| 765 | 765 | |
| 766 | - add_meta( $post_ID ); |
|
| 766 | + add_meta($post_ID); |
|
| 767 | 767 | |
| 768 | - add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); |
|
| 768 | + add_post_meta($post_ID, '_edit_last', $GLOBALS['current_user']->ID); |
|
| 769 | 769 | |
| 770 | 770 | // Now that we have an ID we can fix any attachment anchor hrefs |
| 771 | - _fix_attachment_links( $post_ID ); |
|
| 771 | + _fix_attachment_links($post_ID); |
|
| 772 | 772 | |
| 773 | - wp_set_post_lock( $post_ID ); |
|
| 773 | + wp_set_post_lock($post_ID); |
|
| 774 | 774 | |
| 775 | 775 | return $post_ID; |
| 776 | 776 | } |
@@ -784,8 +784,8 @@ discard block |
||
| 784 | 784 | */ |
| 785 | 785 | function write_post() { |
| 786 | 786 | $result = wp_write_post(); |
| 787 | - if ( is_wp_error( $result ) ) |
|
| 788 | - wp_die( $result->get_error_message() ); |
|
| 787 | + if (is_wp_error($result)) |
|
| 788 | + wp_die($result->get_error_message()); |
|
| 789 | 789 | else |
| 790 | 790 | return $result; |
| 791 | 791 | } |
@@ -802,32 +802,32 @@ discard block |
||
| 802 | 802 | * @param int $post_ID |
| 803 | 803 | * @return int|bool |
| 804 | 804 | */ |
| 805 | -function add_meta( $post_ID ) { |
|
| 805 | +function add_meta($post_ID) { |
|
| 806 | 806 | $post_ID = (int) $post_ID; |
| 807 | 807 | |
| 808 | - $metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : ''; |
|
| 809 | - $metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : ''; |
|
| 808 | + $metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash(trim($_POST['metakeyselect'])) : ''; |
|
| 809 | + $metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash(trim($_POST['metakeyinput'])) : ''; |
|
| 810 | 810 | $metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : ''; |
| 811 | - if ( is_string( $metavalue ) ) |
|
| 812 | - $metavalue = trim( $metavalue ); |
|
| 811 | + if (is_string($metavalue)) |
|
| 812 | + $metavalue = trim($metavalue); |
|
| 813 | 813 | |
| 814 | - if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput ) ) ) { |
|
| 814 | + if (('0' === $metavalue || ! empty ($metavalue)) && ((('#NONE#' != $metakeyselect) && ! empty ($metakeyselect)) || ! empty ($metakeyinput))) { |
|
| 815 | 815 | /* |
| 816 | 816 | * We have a key/value pair. If both the select and the input |
| 817 | 817 | * for the key have data, the input takes precedence. |
| 818 | 818 | */ |
| 819 | - if ( '#NONE#' != $metakeyselect ) |
|
| 819 | + if ('#NONE#' != $metakeyselect) |
|
| 820 | 820 | $metakey = $metakeyselect; |
| 821 | 821 | |
| 822 | - if ( $metakeyinput ) |
|
| 822 | + if ($metakeyinput) |
|
| 823 | 823 | $metakey = $metakeyinput; // default |
| 824 | 824 | |
| 825 | - if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) |
|
| 825 | + if (is_protected_meta($metakey, 'post') || ! current_user_can('add_post_meta', $post_ID, $metakey)) |
|
| 826 | 826 | return false; |
| 827 | 827 | |
| 828 | - $metakey = wp_slash( $metakey ); |
|
| 828 | + $metakey = wp_slash($metakey); |
|
| 829 | 829 | |
| 830 | - return add_post_meta( $post_ID, $metakey, $metavalue ); |
|
| 830 | + return add_post_meta($post_ID, $metakey, $metavalue); |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | return false; |
@@ -841,8 +841,8 @@ discard block |
||
| 841 | 841 | * @param int $mid |
| 842 | 842 | * @return bool |
| 843 | 843 | */ |
| 844 | -function delete_meta( $mid ) { |
|
| 845 | - return delete_metadata_by_mid( 'post' , $mid ); |
|
| 844 | +function delete_meta($mid) { |
|
| 845 | + return delete_metadata_by_mid('post', $mid); |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | /** |
@@ -857,11 +857,11 @@ discard block |
||
| 857 | 857 | function get_meta_keys() { |
| 858 | 858 | global $wpdb; |
| 859 | 859 | |
| 860 | - $keys = $wpdb->get_col( " |
|
| 860 | + $keys = $wpdb->get_col(" |
|
| 861 | 861 | SELECT meta_key |
| 862 | 862 | FROM $wpdb->postmeta |
| 863 | 863 | GROUP BY meta_key |
| 864 | - ORDER BY meta_key" ); |
|
| 864 | + ORDER BY meta_key"); |
|
| 865 | 865 | |
| 866 | 866 | return $keys; |
| 867 | 867 | } |
@@ -874,8 +874,8 @@ discard block |
||
| 874 | 874 | * @param int $mid |
| 875 | 875 | * @return object|bool |
| 876 | 876 | */ |
| 877 | -function get_post_meta_by_id( $mid ) { |
|
| 878 | - return get_metadata_by_mid( 'post', $mid ); |
|
| 877 | +function get_post_meta_by_id($mid) { |
|
| 878 | + return get_metadata_by_mid('post', $mid); |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | /** |
@@ -888,12 +888,12 @@ discard block |
||
| 888 | 888 | * @param int $postid |
| 889 | 889 | * @return mixed |
| 890 | 890 | */ |
| 891 | -function has_meta( $postid ) { |
|
| 891 | +function has_meta($postid) { |
|
| 892 | 892 | global $wpdb; |
| 893 | 893 | |
| 894 | - return $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id |
|
| 894 | + return $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id |
|
| 895 | 895 | FROM $wpdb->postmeta WHERE post_id = %d |
| 896 | - ORDER BY meta_key,meta_id", $postid), ARRAY_A ); |
|
| 896 | + ORDER BY meta_key,meta_id", $postid), ARRAY_A); |
|
| 897 | 897 | } |
| 898 | 898 | |
| 899 | 899 | /** |
@@ -906,11 +906,11 @@ discard block |
||
| 906 | 906 | * @param string $meta_value Expect Slashed |
| 907 | 907 | * @return bool |
| 908 | 908 | */ |
| 909 | -function update_meta( $meta_id, $meta_key, $meta_value ) { |
|
| 910 | - $meta_key = wp_unslash( $meta_key ); |
|
| 911 | - $meta_value = wp_unslash( $meta_value ); |
|
| 909 | +function update_meta($meta_id, $meta_key, $meta_value) { |
|
| 910 | + $meta_key = wp_unslash($meta_key); |
|
| 911 | + $meta_value = wp_unslash($meta_value); |
|
| 912 | 912 | |
| 913 | - return update_metadata_by_mid( 'post', $meta_id, $meta_value, $meta_key ); |
|
| 913 | + return update_metadata_by_mid('post', $meta_id, $meta_value, $meta_key); |
|
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | // |
@@ -926,42 +926,42 @@ discard block |
||
| 926 | 926 | * @param int|object $post Post ID or post object. |
| 927 | 927 | * @return void|int|WP_Error Void if nothing fixed. 0 or WP_Error on update failure. The post ID on update success. |
| 928 | 928 | */ |
| 929 | -function _fix_attachment_links( $post ) { |
|
| 930 | - $post = get_post( $post, ARRAY_A ); |
|
| 929 | +function _fix_attachment_links($post) { |
|
| 930 | + $post = get_post($post, ARRAY_A); |
|
| 931 | 931 | $content = $post['post_content']; |
| 932 | 932 | |
| 933 | 933 | // Don't run if no pretty permalinks or post is not published, scheduled, or privately published. |
| 934 | - if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) |
|
| 934 | + if ( ! get_option('permalink_structure') || ! in_array($post['post_status'], array('publish', 'future', 'private'))) |
|
| 935 | 935 | return; |
| 936 | 936 | |
| 937 | 937 | // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero) |
| 938 | - if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) |
|
| 938 | + if ( ! strpos($content, '?attachment_id=') || ! preg_match_all('/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches)) |
|
| 939 | 939 | return; |
| 940 | 940 | |
| 941 | 941 | $site_url = get_bloginfo('url'); |
| 942 | - $site_url = substr( $site_url, (int) strpos($site_url, '://') ); // remove the http(s) |
|
| 942 | + $site_url = substr($site_url, (int) strpos($site_url, '://')); // remove the http(s) |
|
| 943 | 943 | $replace = ''; |
| 944 | 944 | |
| 945 | - foreach ( $link_matches[1] as $key => $value ) { |
|
| 946 | - if ( !strpos($value, '?attachment_id=') || !strpos($value, 'wp-att-') |
|
| 947 | - || !preg_match( '/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match ) |
|
| 948 | - || !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) ) |
|
| 945 | + foreach ($link_matches[1] as $key => $value) { |
|
| 946 | + if ( ! strpos($value, '?attachment_id=') || ! strpos($value, 'wp-att-') |
|
| 947 | + || ! preg_match('/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match) |
|
| 948 | + || ! preg_match('/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match)) |
|
| 949 | 949 | continue; |
| 950 | 950 | |
| 951 | 951 | $quote = $url_match[1]; // the quote (single or double) |
| 952 | 952 | $url_id = (int) $url_match[2]; |
| 953 | 953 | $rel_id = (int) $rel_match[1]; |
| 954 | 954 | |
| 955 | - if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false ) |
|
| 955 | + if ( ! $url_id || ! $rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false) |
|
| 956 | 956 | continue; |
| 957 | 957 | |
| 958 | 958 | $link = $link_matches[0][$key]; |
| 959 | - $replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote, $link ); |
|
| 959 | + $replace = str_replace($url_match[0], 'href='.$quote.get_attachment_link($url_id).$quote, $link); |
|
| 960 | 960 | |
| 961 | - $content = str_replace( $link, $replace, $content ); |
|
| 961 | + $content = str_replace($link, $replace, $content); |
|
| 962 | 962 | } |
| 963 | 963 | |
| 964 | - if ( $replace ) { |
|
| 964 | + if ($replace) { |
|
| 965 | 965 | $post['post_content'] = $content; |
| 966 | 966 | // Escape data pulled from DB. |
| 967 | 967 | $post = add_magic_quotes($post); |
@@ -992,40 +992,40 @@ discard block |
||
| 992 | 992 | * @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal. |
| 993 | 993 | * @return array |
| 994 | 994 | */ |
| 995 | -function wp_edit_posts_query( $q = false ) { |
|
| 996 | - if ( false === $q ) |
|
| 995 | +function wp_edit_posts_query($q = false) { |
|
| 996 | + if (false === $q) |
|
| 997 | 997 | $q = $_GET; |
| 998 | 998 | $q['m'] = isset($q['m']) ? (int) $q['m'] : 0; |
| 999 | 999 | $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; |
| 1000 | - $post_stati = get_post_stati(); |
|
| 1000 | + $post_stati = get_post_stati(); |
|
| 1001 | 1001 | |
| 1002 | - if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) ) |
|
| 1002 | + if (isset($q['post_type']) && in_array($q['post_type'], get_post_types())) |
|
| 1003 | 1003 | $post_type = $q['post_type']; |
| 1004 | 1004 | else |
| 1005 | 1005 | $post_type = 'post'; |
| 1006 | 1006 | |
| 1007 | 1007 | $avail_post_stati = get_available_post_statuses($post_type); |
| 1008 | 1008 | |
| 1009 | - if ( isset($q['post_status']) && in_array( $q['post_status'], $post_stati ) ) { |
|
| 1009 | + if (isset($q['post_status']) && in_array($q['post_status'], $post_stati)) { |
|
| 1010 | 1010 | $post_status = $q['post_status']; |
| 1011 | 1011 | $perm = 'readable'; |
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | - if ( isset( $q['orderby'] ) ) { |
|
| 1014 | + if (isset($q['orderby'])) { |
|
| 1015 | 1015 | $orderby = $q['orderby']; |
| 1016 | - } elseif ( isset( $q['post_status'] ) && in_array( $q['post_status'], array( 'pending', 'draft' ) ) ) { |
|
| 1016 | + } elseif (isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft'))) { |
|
| 1017 | 1017 | $orderby = 'modified'; |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | - if ( isset( $q['order'] ) ) { |
|
| 1020 | + if (isset($q['order'])) { |
|
| 1021 | 1021 | $order = $q['order']; |
| 1022 | - } elseif ( isset( $q['post_status'] ) && 'pending' == $q['post_status'] ) { |
|
| 1022 | + } elseif (isset($q['post_status']) && 'pending' == $q['post_status']) { |
|
| 1023 | 1023 | $order = 'ASC'; |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | $per_page = "edit_{$post_type}_per_page"; |
| 1027 | - $posts_per_page = (int) get_user_option( $per_page ); |
|
| 1028 | - if ( empty( $posts_per_page ) || $posts_per_page < 1 ) |
|
| 1027 | + $posts_per_page = (int) get_user_option($per_page); |
|
| 1028 | + if (empty($posts_per_page) || $posts_per_page < 1) |
|
| 1029 | 1029 | $posts_per_page = 20; |
| 1030 | 1030 | |
| 1031 | 1031 | /** |
@@ -1041,7 +1041,7 @@ discard block |
||
| 1041 | 1041 | * @param int $posts_per_page Number of posts to display per page for the given post |
| 1042 | 1042 | * type. Default 20. |
| 1043 | 1043 | */ |
| 1044 | - $posts_per_page = apply_filters( "edit_{$post_type}_per_page", $posts_per_page ); |
|
| 1044 | + $posts_per_page = apply_filters("edit_{$post_type}_per_page", $posts_per_page); |
|
| 1045 | 1045 | |
| 1046 | 1046 | /** |
| 1047 | 1047 | * Filters the number of posts displayed per page when specifically listing "posts". |
@@ -1051,12 +1051,12 @@ discard block |
||
| 1051 | 1051 | * @param int $posts_per_page Number of posts to be displayed. Default 20. |
| 1052 | 1052 | * @param string $post_type The post type. |
| 1053 | 1053 | */ |
| 1054 | - $posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page, $post_type ); |
|
| 1054 | + $posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page, $post_type); |
|
| 1055 | 1055 | |
| 1056 | 1056 | $query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page'); |
| 1057 | 1057 | |
| 1058 | 1058 | // Hierarchical types require special args. |
| 1059 | - if ( is_post_type_hierarchical( $post_type ) && !isset($orderby) ) { |
|
| 1059 | + if (is_post_type_hierarchical($post_type) && ! isset($orderby)) { |
|
| 1060 | 1060 | $query['orderby'] = 'menu_order title'; |
| 1061 | 1061 | $query['order'] = 'asc'; |
| 1062 | 1062 | $query['posts_per_page'] = -1; |
@@ -1064,10 +1064,10 @@ discard block |
||
| 1064 | 1064 | $query['fields'] = 'id=>parent'; |
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | - if ( ! empty( $q['show_sticky'] ) ) |
|
| 1068 | - $query['post__in'] = (array) get_option( 'sticky_posts' ); |
|
| 1067 | + if ( ! empty($q['show_sticky'])) |
|
| 1068 | + $query['post__in'] = (array) get_option('sticky_posts'); |
|
| 1069 | 1069 | |
| 1070 | - wp( $query ); |
|
| 1070 | + wp($query); |
|
| 1071 | 1071 | |
| 1072 | 1072 | return $avail_post_stati; |
| 1073 | 1073 | } |
@@ -1098,24 +1098,24 @@ discard block |
||
| 1098 | 1098 | * to use $_GET superglobal. Default false. |
| 1099 | 1099 | * @return array The parsed query vars. |
| 1100 | 1100 | */ |
| 1101 | -function wp_edit_attachments_query_vars( $q = false ) { |
|
| 1102 | - if ( false === $q ) { |
|
| 1101 | +function wp_edit_attachments_query_vars($q = false) { |
|
| 1102 | + if (false === $q) { |
|
| 1103 | 1103 | $q = $_GET; |
| 1104 | 1104 | } |
| 1105 | - $q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0; |
|
| 1106 | - $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0; |
|
| 1105 | + $q['m'] = isset($q['m']) ? (int) $q['m'] : 0; |
|
| 1106 | + $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; |
|
| 1107 | 1107 | $q['post_type'] = 'attachment'; |
| 1108 | - $post_type = get_post_type_object( 'attachment' ); |
|
| 1108 | + $post_type = get_post_type_object('attachment'); |
|
| 1109 | 1109 | $states = 'inherit'; |
| 1110 | - if ( current_user_can( $post_type->cap->read_private_posts ) ) { |
|
| 1110 | + if (current_user_can($post_type->cap->read_private_posts)) { |
|
| 1111 | 1111 | $states .= ',private'; |
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | - $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states; |
|
| 1115 | - $q['post_status'] = isset( $q['attachment-filter'] ) && 'trash' == $q['attachment-filter'] ? 'trash' : $states; |
|
| 1114 | + $q['post_status'] = isset($q['status']) && 'trash' == $q['status'] ? 'trash' : $states; |
|
| 1115 | + $q['post_status'] = isset($q['attachment-filter']) && 'trash' == $q['attachment-filter'] ? 'trash' : $states; |
|
| 1116 | 1116 | |
| 1117 | - $media_per_page = (int) get_user_option( 'upload_per_page' ); |
|
| 1118 | - if ( empty( $media_per_page ) || $media_per_page < 1 ) { |
|
| 1117 | + $media_per_page = (int) get_user_option('upload_per_page'); |
|
| 1118 | + if (empty($media_per_page) || $media_per_page < 1) { |
|
| 1119 | 1119 | $media_per_page = 20; |
| 1120 | 1120 | } |
| 1121 | 1121 | |
@@ -1126,21 +1126,21 @@ discard block |
||
| 1126 | 1126 | * |
| 1127 | 1127 | * @param int $media_per_page Number of media to list. Default 20. |
| 1128 | 1128 | */ |
| 1129 | - $q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page ); |
|
| 1129 | + $q['posts_per_page'] = apply_filters('upload_per_page', $media_per_page); |
|
| 1130 | 1130 | |
| 1131 | 1131 | $post_mime_types = get_post_mime_types(); |
| 1132 | - if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) { |
|
| 1132 | + if (isset($q['post_mime_type']) && ! array_intersect((array) $q['post_mime_type'], array_keys($post_mime_types))) { |
|
| 1133 | 1133 | unset($q['post_mime_type']); |
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | - foreach ( array_keys( $post_mime_types ) as $type ) { |
|
| 1137 | - if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" == $q['attachment-filter'] ) { |
|
| 1136 | + foreach (array_keys($post_mime_types) as $type) { |
|
| 1137 | + if (isset($q['attachment-filter']) && "post_mime_type:$type" == $q['attachment-filter']) { |
|
| 1138 | 1138 | $q['post_mime_type'] = $type; |
| 1139 | 1139 | break; |
| 1140 | 1140 | } |
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | - if ( isset( $q['detached'] ) || ( isset( $q['attachment-filter'] ) && 'detached' == $q['attachment-filter'] ) ) { |
|
| 1143 | + if (isset($q['detached']) || (isset($q['attachment-filter']) && 'detached' == $q['attachment-filter'])) { |
|
| 1144 | 1144 | $q['post_parent'] = 0; |
| 1145 | 1145 | } |
| 1146 | 1146 | |
@@ -1156,13 +1156,13 @@ discard block |
||
| 1156 | 1156 | * @param array|false $q Array of query variables to use to build the query or false to use $_GET superglobal. |
| 1157 | 1157 | * @return array |
| 1158 | 1158 | */ |
| 1159 | -function wp_edit_attachments_query( $q = false ) { |
|
| 1160 | - wp( wp_edit_attachments_query_vars( $q ) ); |
|
| 1159 | +function wp_edit_attachments_query($q = false) { |
|
| 1160 | + wp(wp_edit_attachments_query_vars($q)); |
|
| 1161 | 1161 | |
| 1162 | 1162 | $post_mime_types = get_post_mime_types(); |
| 1163 | - $avail_post_mime_types = get_available_post_mime_types( 'attachment' ); |
|
| 1163 | + $avail_post_mime_types = get_available_post_mime_types('attachment'); |
|
| 1164 | 1164 | |
| 1165 | - return array( $post_mime_types, $avail_post_mime_types ); |
|
| 1165 | + return array($post_mime_types, $avail_post_mime_types); |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | /** |
@@ -1174,17 +1174,17 @@ discard block |
||
| 1174 | 1174 | * @param string $page |
| 1175 | 1175 | * @return string |
| 1176 | 1176 | */ |
| 1177 | -function postbox_classes( $id, $page ) { |
|
| 1178 | - if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id ) { |
|
| 1179 | - $classes = array( '' ); |
|
| 1180 | - } elseif ( $closed = get_user_option('closedpostboxes_'.$page ) ) { |
|
| 1181 | - if ( !is_array( $closed ) ) { |
|
| 1182 | - $classes = array( '' ); |
|
| 1177 | +function postbox_classes($id, $page) { |
|
| 1178 | + if (isset($_GET['edit']) && $_GET['edit'] == $id) { |
|
| 1179 | + $classes = array(''); |
|
| 1180 | + } elseif ($closed = get_user_option('closedpostboxes_'.$page)) { |
|
| 1181 | + if ( ! is_array($closed)) { |
|
| 1182 | + $classes = array(''); |
|
| 1183 | 1183 | } else { |
| 1184 | - $classes = in_array( $id, $closed ) ? array( 'closed' ) : array( '' ); |
|
| 1184 | + $classes = in_array($id, $closed) ? array('closed') : array(''); |
|
| 1185 | 1185 | } |
| 1186 | 1186 | } else { |
| 1187 | - $classes = array( '' ); |
|
| 1187 | + $classes = array(''); |
|
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | 1190 | /** |
@@ -1197,8 +1197,8 @@ discard block |
||
| 1197 | 1197 | * |
| 1198 | 1198 | * @param array $classes An array of postbox classes. |
| 1199 | 1199 | */ |
| 1200 | - $classes = apply_filters( "postbox_classes_{$page}_{$id}", $classes ); |
|
| 1201 | - return implode( ' ', $classes ); |
|
| 1200 | + $classes = apply_filters("postbox_classes_{$page}_{$id}", $classes); |
|
| 1201 | + return implode(' ', $classes); |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | /** |
@@ -1212,9 +1212,9 @@ discard block |
||
| 1212 | 1212 | * @return array Array with two entries of type string. |
| 1213 | 1213 | */ |
| 1214 | 1214 | function get_sample_permalink($id, $title = null, $name = null) { |
| 1215 | - $post = get_post( $id ); |
|
| 1216 | - if ( ! $post ) |
|
| 1217 | - return array( '', '' ); |
|
| 1215 | + $post = get_post($id); |
|
| 1216 | + if ( ! $post) |
|
| 1217 | + return array('', ''); |
|
| 1218 | 1218 | |
| 1219 | 1219 | $ptype = get_post_type_object($post->post_type); |
| 1220 | 1220 | |
@@ -1223,14 +1223,14 @@ discard block |
||
| 1223 | 1223 | $original_name = $post->post_name; |
| 1224 | 1224 | |
| 1225 | 1225 | // Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published. |
| 1226 | - if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ) ) ) { |
|
| 1226 | + if (in_array($post->post_status, array('draft', 'pending', 'future'))) { |
|
| 1227 | 1227 | $post->post_status = 'publish'; |
| 1228 | 1228 | $post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID); |
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | 1231 | // If the user wants to set a new name -- override the current one |
| 1232 | 1232 | // Note: if empty name is supplied -- use the title instead, see #6072 |
| 1233 | - if ( !is_null($name) ) |
|
| 1233 | + if ( ! is_null($name)) |
|
| 1234 | 1234 | $post->post_name = sanitize_title($name ? $name : $title, $post->ID); |
| 1235 | 1235 | |
| 1236 | 1236 | $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent); |
@@ -1243,23 +1243,23 @@ discard block |
||
| 1243 | 1243 | $permalink = str_replace("%$post->post_type%", '%pagename%', $permalink); |
| 1244 | 1244 | |
| 1245 | 1245 | // Handle page hierarchy |
| 1246 | - if ( $ptype->hierarchical ) { |
|
| 1246 | + if ($ptype->hierarchical) { |
|
| 1247 | 1247 | $uri = get_page_uri($post); |
| 1248 | - if ( $uri ) { |
|
| 1248 | + if ($uri) { |
|
| 1249 | 1249 | $uri = untrailingslashit($uri); |
| 1250 | - $uri = strrev( stristr( strrev( $uri ), '/' ) ); |
|
| 1250 | + $uri = strrev(stristr(strrev($uri), '/')); |
|
| 1251 | 1251 | $uri = untrailingslashit($uri); |
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | 1254 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
| 1255 | - $uri = apply_filters( 'editable_slug', $uri, $post ); |
|
| 1256 | - if ( !empty($uri) ) |
|
| 1255 | + $uri = apply_filters('editable_slug', $uri, $post); |
|
| 1256 | + if ( ! empty($uri)) |
|
| 1257 | 1257 | $uri .= '/'; |
| 1258 | 1258 | $permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink); |
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
| 1262 | - $permalink = array( $permalink, apply_filters( 'editable_slug', $post->post_name, $post ) ); |
|
| 1262 | + $permalink = array($permalink, apply_filters('editable_slug', $post->post_name, $post)); |
|
| 1263 | 1263 | $post->post_status = $original_status; |
| 1264 | 1264 | $post->post_date = $original_date; |
| 1265 | 1265 | $post->post_name = $original_name; |
@@ -1276,7 +1276,7 @@ discard block |
||
| 1276 | 1276 | * @param string $name Post name (slug). |
| 1277 | 1277 | * @param WP_Post $post Post object. |
| 1278 | 1278 | */ |
| 1279 | - return apply_filters( 'get_sample_permalink', $permalink, $post->ID, $title, $name, $post ); |
|
| 1279 | + return apply_filters('get_sample_permalink', $permalink, $post->ID, $title, $name, $post); |
|
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | 1282 | /** |
@@ -1289,9 +1289,9 @@ discard block |
||
| 1289 | 1289 | * @param string $new_slug Optional. New slug. Default null. |
| 1290 | 1290 | * @return string The HTML of the sample permalink slug editor. |
| 1291 | 1291 | */ |
| 1292 | -function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { |
|
| 1293 | - $post = get_post( $id ); |
|
| 1294 | - if ( ! $post ) |
|
| 1292 | +function get_sample_permalink_html($id, $new_title = null, $new_slug = null) { |
|
| 1293 | + $post = get_post($id); |
|
| 1294 | + if ( ! $post) |
|
| 1295 | 1295 | return ''; |
| 1296 | 1296 | |
| 1297 | 1297 | list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); |
@@ -1299,50 +1299,50 @@ discard block |
||
| 1299 | 1299 | $view_link = false; |
| 1300 | 1300 | $preview_target = ''; |
| 1301 | 1301 | |
| 1302 | - if ( current_user_can( 'read_post', $post->ID ) ) { |
|
| 1303 | - if ( 'draft' === $post->post_status ) { |
|
| 1304 | - $view_link = get_preview_post_link( $post ); |
|
| 1302 | + if (current_user_can('read_post', $post->ID)) { |
|
| 1303 | + if ('draft' === $post->post_status) { |
|
| 1304 | + $view_link = get_preview_post_link($post); |
|
| 1305 | 1305 | $preview_target = " target='wp-preview-{$post->ID}'"; |
| 1306 | 1306 | } else { |
| 1307 | - if ( 'publish' === $post->post_status || 'attachment' === $post->post_type ) { |
|
| 1308 | - $view_link = get_permalink( $post ); |
|
| 1307 | + if ('publish' === $post->post_status || 'attachment' === $post->post_type) { |
|
| 1308 | + $view_link = get_permalink($post); |
|
| 1309 | 1309 | } else { |
| 1310 | 1310 | // Allow non-published (private, future) to be viewed at a pretty permalink. |
| 1311 | - $view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, $permalink ); |
|
| 1311 | + $view_link = str_replace(array('%pagename%', '%postname%'), $post->post_name, $permalink); |
|
| 1312 | 1312 | } |
| 1313 | 1313 | } |
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | // Permalinks without a post/page name placeholder don't have anything to edit |
| 1317 | - if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) { |
|
| 1318 | - $return = '<strong>' . __( 'Permalink:' ) . "</strong>\n"; |
|
| 1317 | + if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) { |
|
| 1318 | + $return = '<strong>'.__('Permalink:')."</strong>\n"; |
|
| 1319 | 1319 | |
| 1320 | - if ( false !== $view_link ) { |
|
| 1321 | - $display_link = urldecode( $view_link ); |
|
| 1322 | - $return .= '<a id="sample-permalink" href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . esc_html( $display_link ) . "</a>\n"; |
|
| 1320 | + if (false !== $view_link) { |
|
| 1321 | + $display_link = urldecode($view_link); |
|
| 1322 | + $return .= '<a id="sample-permalink" href="'.esc_url($view_link).'"'.$preview_target.'>'.esc_html($display_link)."</a>\n"; |
|
| 1323 | 1323 | } else { |
| 1324 | - $return .= '<span id="sample-permalink">' . $permalink . "</span>\n"; |
|
| 1324 | + $return .= '<span id="sample-permalink">'.$permalink."</span>\n"; |
|
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | 1327 | // Encourage a pretty permalink setting |
| 1328 | - if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) { |
|
| 1329 | - $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n"; |
|
| 1328 | + if ('' == get_option('permalink_structure') && current_user_can('manage_options') && ! ('page' == get_option('show_on_front') && $id == get_option('page_on_front'))) { |
|
| 1329 | + $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">'.__('Change Permalinks')."</a></span>\n"; |
|
| 1330 | 1330 | } |
| 1331 | 1331 | } else { |
| 1332 | - if ( mb_strlen( $post_name ) > 34 ) { |
|
| 1333 | - $post_name_abridged = mb_substr( $post_name, 0, 16 ) . '…' . mb_substr( $post_name, -16 ); |
|
| 1332 | + if (mb_strlen($post_name) > 34) { |
|
| 1333 | + $post_name_abridged = mb_substr($post_name, 0, 16).'…'.mb_substr($post_name, -16); |
|
| 1334 | 1334 | } else { |
| 1335 | 1335 | $post_name_abridged = $post_name; |
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | - $post_name_html = '<span id="editable-post-name">' . esc_html( $post_name_abridged ) . '</span>'; |
|
| 1339 | - $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, esc_html( urldecode( $permalink ) ) ); |
|
| 1338 | + $post_name_html = '<span id="editable-post-name">'.esc_html($post_name_abridged).'</span>'; |
|
| 1339 | + $display_link = str_replace(array('%pagename%', '%postname%'), $post_name_html, esc_html(urldecode($permalink))); |
|
| 1340 | 1340 | |
| 1341 | - $return = '<strong>' . __( 'Permalink:' ) . "</strong>\n"; |
|
| 1342 | - $return .= '<span id="sample-permalink"><a href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $display_link . "</a></span>\n"; |
|
| 1341 | + $return = '<strong>'.__('Permalink:')."</strong>\n"; |
|
| 1342 | + $return .= '<span id="sample-permalink"><a href="'.esc_url($view_link).'"'.$preview_target.'>'.$display_link."</a></span>\n"; |
|
| 1343 | 1343 | $return .= '‎'; // Fix bi-directional text display defect in RTL languages. |
| 1344 | - $return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js" aria-label="' . __( 'Edit permalink' ) . '">' . __( 'Edit' ) . "</button></span>\n"; |
|
| 1345 | - $return .= '<span id="editable-post-name-full">' . esc_html( $post_name ) . "</span>\n"; |
|
| 1344 | + $return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js" aria-label="'.__('Edit permalink').'">'.__('Edit')."</button></span>\n"; |
|
| 1345 | + $return .= '<span id="editable-post-name-full">'.esc_html($post_name)."</span>\n"; |
|
| 1346 | 1346 | } |
| 1347 | 1347 | |
| 1348 | 1348 | /** |
@@ -1357,7 +1357,7 @@ discard block |
||
| 1357 | 1357 | * @param string $new_slug New sample permalink slug. |
| 1358 | 1358 | * @param WP_Post $post Post object. |
| 1359 | 1359 | */ |
| 1360 | - $return = apply_filters( 'get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post ); |
|
| 1360 | + $return = apply_filters('get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post); |
|
| 1361 | 1361 | |
| 1362 | 1362 | return $return; |
| 1363 | 1363 | } |
@@ -1373,22 +1373,22 @@ discard block |
||
| 1373 | 1373 | * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post. |
| 1374 | 1374 | * @return string html |
| 1375 | 1375 | */ |
| 1376 | -function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { |
|
| 1376 | +function _wp_post_thumbnail_html($thumbnail_id = null, $post = null) { |
|
| 1377 | 1377 | global $_wp_additional_image_sizes; |
| 1378 | 1378 | |
| 1379 | - $post = get_post( $post ); |
|
| 1380 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
| 1379 | + $post = get_post($post); |
|
| 1380 | + $post_type_object = get_post_type_object($post->post_type); |
|
| 1381 | 1381 | $set_thumbnail_link = '<p class="hide-if-no-js"><a href="%s" id="set-post-thumbnail"%s class="thickbox">%s</a></p>'; |
| 1382 | - $upload_iframe_src = get_upload_iframe_src( 'image', $post->ID ); |
|
| 1382 | + $upload_iframe_src = get_upload_iframe_src('image', $post->ID); |
|
| 1383 | 1383 | |
| 1384 | - $content = sprintf( $set_thumbnail_link, |
|
| 1385 | - esc_url( $upload_iframe_src ), |
|
| 1384 | + $content = sprintf($set_thumbnail_link, |
|
| 1385 | + esc_url($upload_iframe_src), |
|
| 1386 | 1386 | '', // Empty when there's no featured image set, `aria-describedby` attribute otherwise. |
| 1387 | - esc_html( $post_type_object->labels->set_featured_image ) |
|
| 1387 | + esc_html($post_type_object->labels->set_featured_image) |
|
| 1388 | 1388 | ); |
| 1389 | 1389 | |
| 1390 | - if ( $thumbnail_id && get_post( $thumbnail_id ) ) { |
|
| 1391 | - $size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : array( 266, 266 ); |
|
| 1390 | + if ($thumbnail_id && get_post($thumbnail_id)) { |
|
| 1391 | + $size = isset($_wp_additional_image_sizes['post-thumbnail']) ? 'post-thumbnail' : array(266, 266); |
|
| 1392 | 1392 | |
| 1393 | 1393 | /** |
| 1394 | 1394 | * Filters the size used to display the post thumbnail image in the 'Featured Image' meta box. |
@@ -1407,22 +1407,22 @@ discard block |
||
| 1407 | 1407 | * @param int $thumbnail_id Post thumbnail attachment ID. |
| 1408 | 1408 | * @param WP_Post $post The post object associated with the thumbnail. |
| 1409 | 1409 | */ |
| 1410 | - $size = apply_filters( 'admin_post_thumbnail_size', $size, $thumbnail_id, $post ); |
|
| 1410 | + $size = apply_filters('admin_post_thumbnail_size', $size, $thumbnail_id, $post); |
|
| 1411 | 1411 | |
| 1412 | - $thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size ); |
|
| 1412 | + $thumbnail_html = wp_get_attachment_image($thumbnail_id, $size); |
|
| 1413 | 1413 | |
| 1414 | - if ( ! empty( $thumbnail_html ) ) { |
|
| 1415 | - $content = sprintf( $set_thumbnail_link, |
|
| 1416 | - esc_url( $upload_iframe_src ), |
|
| 1414 | + if ( ! empty($thumbnail_html)) { |
|
| 1415 | + $content = sprintf($set_thumbnail_link, |
|
| 1416 | + esc_url($upload_iframe_src), |
|
| 1417 | 1417 | ' aria-describedby="set-post-thumbnail-desc"', |
| 1418 | 1418 | $thumbnail_html |
| 1419 | 1419 | ); |
| 1420 | - $content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">' . __( 'Click the image to edit or update' ) . '</p>'; |
|
| 1421 | - $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail">' . esc_html( $post_type_object->labels->remove_featured_image ) . '</a></p>'; |
|
| 1420 | + $content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">'.__('Click the image to edit or update').'</p>'; |
|
| 1421 | + $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail">'.esc_html($post_type_object->labels->remove_featured_image).'</a></p>'; |
|
| 1422 | 1422 | } |
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | - $content .= '<input type="hidden" id="_thumbnail_id" name="_thumbnail_id" value="' . esc_attr( $thumbnail_id ? $thumbnail_id : '-1' ) . '" />'; |
|
| 1425 | + $content .= '<input type="hidden" id="_thumbnail_id" name="_thumbnail_id" value="'.esc_attr($thumbnail_id ? $thumbnail_id : '-1').'" />'; |
|
| 1426 | 1426 | |
| 1427 | 1427 | /** |
| 1428 | 1428 | * Filters the admin post thumbnail HTML markup to return. |
@@ -1435,7 +1435,7 @@ discard block |
||
| 1435 | 1435 | * @param int $post_id Post ID. |
| 1436 | 1436 | * @param int $thumbnail_id Thumbnail ID. |
| 1437 | 1437 | */ |
| 1438 | - return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID, $thumbnail_id ); |
|
| 1438 | + return apply_filters('admin_post_thumbnail_html', $content, $post->ID, $thumbnail_id); |
|
| 1439 | 1439 | } |
| 1440 | 1440 | |
| 1441 | 1441 | /** |
@@ -1446,21 +1446,21 @@ discard block |
||
| 1446 | 1446 | * @param int $post_id ID of the post to check for editing |
| 1447 | 1447 | * @return integer False: not locked or locked by current user. Int: user ID of user with lock. |
| 1448 | 1448 | */ |
| 1449 | -function wp_check_post_lock( $post_id ) { |
|
| 1450 | - if ( !$post = get_post( $post_id ) ) |
|
| 1449 | +function wp_check_post_lock($post_id) { |
|
| 1450 | + if ( ! $post = get_post($post_id)) |
|
| 1451 | 1451 | return false; |
| 1452 | 1452 | |
| 1453 | - if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) |
|
| 1453 | + if ( ! $lock = get_post_meta($post->ID, '_edit_lock', true)) |
|
| 1454 | 1454 | return false; |
| 1455 | 1455 | |
| 1456 | - $lock = explode( ':', $lock ); |
|
| 1456 | + $lock = explode(':', $lock); |
|
| 1457 | 1457 | $time = $lock[0]; |
| 1458 | - $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); |
|
| 1458 | + $user = isset($lock[1]) ? $lock[1] : get_post_meta($post->ID, '_edit_last', true); |
|
| 1459 | 1459 | |
| 1460 | 1460 | /** This filter is documented in wp-admin/includes/ajax-actions.php */ |
| 1461 | - $time_window = apply_filters( 'wp_check_post_lock_window', 150 ); |
|
| 1461 | + $time_window = apply_filters('wp_check_post_lock_window', 150); |
|
| 1462 | 1462 | |
| 1463 | - if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) |
|
| 1463 | + if ($time && $time > time() - $time_window && $user != get_current_user_id()) |
|
| 1464 | 1464 | return $user; |
| 1465 | 1465 | return false; |
| 1466 | 1466 | } |
@@ -1474,17 +1474,17 @@ discard block |
||
| 1474 | 1474 | * @return bool|array Returns false if the post doesn't exist of there is no current user, or |
| 1475 | 1475 | * an array of the lock time and the user ID. |
| 1476 | 1476 | */ |
| 1477 | -function wp_set_post_lock( $post_id ) { |
|
| 1478 | - if ( !$post = get_post( $post_id ) ) |
|
| 1477 | +function wp_set_post_lock($post_id) { |
|
| 1478 | + if ( ! $post = get_post($post_id)) |
|
| 1479 | 1479 | return false; |
| 1480 | - if ( 0 == ($user_id = get_current_user_id()) ) |
|
| 1480 | + if (0 == ($user_id = get_current_user_id())) |
|
| 1481 | 1481 | return false; |
| 1482 | 1482 | |
| 1483 | 1483 | $now = time(); |
| 1484 | 1484 | $lock = "$now:$user_id"; |
| 1485 | 1485 | |
| 1486 | - update_post_meta( $post->ID, '_edit_lock', $lock ); |
|
| 1487 | - return array( $now, $user_id ); |
|
| 1486 | + update_post_meta($post->ID, '_edit_lock', $lock); |
|
| 1487 | + return array($now, $user_id); |
|
| 1488 | 1488 | } |
| 1489 | 1489 | |
| 1490 | 1490 | /** |
@@ -1494,14 +1494,14 @@ discard block |
||
| 1494 | 1494 | * @return none |
| 1495 | 1495 | */ |
| 1496 | 1496 | function _admin_notice_post_locked() { |
| 1497 | - if ( ! $post = get_post() ) |
|
| 1497 | + if ( ! $post = get_post()) |
|
| 1498 | 1498 | return; |
| 1499 | 1499 | |
| 1500 | 1500 | $user = null; |
| 1501 | - if ( $user_id = wp_check_post_lock( $post->ID ) ) |
|
| 1502 | - $user = get_userdata( $user_id ); |
|
| 1501 | + if ($user_id = wp_check_post_lock($post->ID)) |
|
| 1502 | + $user = get_userdata($user_id); |
|
| 1503 | 1503 | |
| 1504 | - if ( $user ) { |
|
| 1504 | + if ($user) { |
|
| 1505 | 1505 | |
| 1506 | 1506 | /** |
| 1507 | 1507 | * Filters whether to show the post locked dialog. |
@@ -1513,7 +1513,7 @@ discard block |
||
| 1513 | 1513 | * @param bool $display Whether to display the dialog. Default true. |
| 1514 | 1514 | * @param WP_User|bool $user WP_User object on success, false otherwise. |
| 1515 | 1515 | */ |
| 1516 | - if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) |
|
| 1516 | + if ( ! apply_filters('show_post_locked_dialog', true, $post, $user)) |
|
| 1517 | 1517 | return; |
| 1518 | 1518 | |
| 1519 | 1519 | $locked = true; |
@@ -1521,17 +1521,17 @@ discard block |
||
| 1521 | 1521 | $locked = false; |
| 1522 | 1522 | } |
| 1523 | 1523 | |
| 1524 | - if ( $locked && ( $sendback = wp_get_referer() ) && |
|
| 1525 | - false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) { |
|
| 1524 | + if ($locked && ($sendback = wp_get_referer()) && |
|
| 1525 | + false === strpos($sendback, 'post.php') && false === strpos($sendback, 'post-new.php')) { |
|
| 1526 | 1526 | |
| 1527 | 1527 | $sendback_text = __('Go back'); |
| 1528 | 1528 | } else { |
| 1529 | - $sendback = admin_url( 'edit.php' ); |
|
| 1529 | + $sendback = admin_url('edit.php'); |
|
| 1530 | 1530 | |
| 1531 | - if ( 'post' != $post->post_type ) |
|
| 1532 | - $sendback = add_query_arg( 'post_type', $post->post_type, $sendback ); |
|
| 1531 | + if ('post' != $post->post_type) |
|
| 1532 | + $sendback = add_query_arg('post_type', $post->post_type, $sendback); |
|
| 1533 | 1533 | |
| 1534 | - $sendback_text = get_post_type_object( $post->post_type )->labels->all_items; |
|
| 1534 | + $sendback_text = get_post_type_object($post->post_type)->labels->all_items; |
|
| 1535 | 1535 | } |
| 1536 | 1536 | |
| 1537 | 1537 | $hidden = $locked ? '' : ' hidden'; |
@@ -1542,18 +1542,18 @@ discard block |
||
| 1542 | 1542 | <div class="notification-dialog"> |
| 1543 | 1543 | <?php |
| 1544 | 1544 | |
| 1545 | - if ( $locked ) { |
|
| 1545 | + if ($locked) { |
|
| 1546 | 1546 | $query_args = array(); |
| 1547 | - if ( get_post_type_object( $post->post_type )->public ) { |
|
| 1548 | - if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) { |
|
| 1547 | + if (get_post_type_object($post->post_type)->public) { |
|
| 1548 | + if ('publish' == $post->post_status || $user->ID != $post->post_author) { |
|
| 1549 | 1549 | // Latest content is in autosave |
| 1550 | - $nonce = wp_create_nonce( 'post_preview_' . $post->ID ); |
|
| 1550 | + $nonce = wp_create_nonce('post_preview_'.$post->ID); |
|
| 1551 | 1551 | $query_args['preview_id'] = $post->ID; |
| 1552 | 1552 | $query_args['preview_nonce'] = $nonce; |
| 1553 | 1553 | } |
| 1554 | 1554 | } |
| 1555 | 1555 | |
| 1556 | - $preview_link = get_preview_post_link( $post->ID, $query_args ); |
|
| 1556 | + $preview_link = get_preview_post_link($post->ID, $query_args); |
|
| 1557 | 1557 | |
| 1558 | 1558 | /** |
| 1559 | 1559 | * Filters whether to allow the post lock to be overridden. |
@@ -1567,17 +1567,17 @@ discard block |
||
| 1567 | 1567 | * @param WP_Post $post Post object. |
| 1568 | 1568 | * @param WP_User $user User object. |
| 1569 | 1569 | */ |
| 1570 | - $override = apply_filters( 'override_post_lock', true, $post, $user ); |
|
| 1570 | + $override = apply_filters('override_post_lock', true, $post, $user); |
|
| 1571 | 1571 | $tab_last = $override ? '' : ' wp-tab-last'; |
| 1572 | 1572 | |
| 1573 | 1573 | ?> |
| 1574 | 1574 | <div class="post-locked-message"> |
| 1575 | - <div class="post-locked-avatar"><?php echo get_avatar( $user->ID, 64 ); ?></div> |
|
| 1575 | + <div class="post-locked-avatar"><?php echo get_avatar($user->ID, 64); ?></div> |
|
| 1576 | 1576 | <p class="currently-editing wp-tab-first" tabindex="0"> |
| 1577 | 1577 | <?php |
| 1578 | - _e( 'This content is currently locked.' ); |
|
| 1579 | - if ( $override ) |
|
| 1580 | - printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) ); |
|
| 1578 | + _e('This content is currently locked.'); |
|
| 1579 | + if ($override) |
|
| 1580 | + printf(' '.__('If you take over, %s will be blocked from continuing to edit.'), esc_html($user->display_name)); |
|
| 1581 | 1581 | ?> |
| 1582 | 1582 | </p> |
| 1583 | 1583 | <?php |
@@ -1588,19 +1588,19 @@ discard block |
||
| 1588 | 1588 | * |
| 1589 | 1589 | * @param WP_Post $post Post object. |
| 1590 | 1590 | */ |
| 1591 | - do_action( 'post_locked_dialog', $post ); |
|
| 1591 | + do_action('post_locked_dialog', $post); |
|
| 1592 | 1592 | ?> |
| 1593 | 1593 | <p> |
| 1594 | - <a class="button" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a> |
|
| 1595 | - <?php if ( $preview_link ) { ?> |
|
| 1596 | - <a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url( $preview_link ); ?>"><?php _e('Preview'); ?></a> |
|
| 1594 | + <a class="button" href="<?php echo esc_url($sendback); ?>"><?php echo $sendback_text; ?></a> |
|
| 1595 | + <?php if ($preview_link) { ?> |
|
| 1596 | + <a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url($preview_link); ?>"><?php _e('Preview'); ?></a> |
|
| 1597 | 1597 | <?php |
| 1598 | 1598 | } |
| 1599 | 1599 | |
| 1600 | 1600 | // Allow plugins to prevent some users overriding the post lock |
| 1601 | - if ( $override ) { |
|
| 1601 | + if ($override) { |
|
| 1602 | 1602 | ?> |
| 1603 | - <a class="button button-primary wp-tab-last" href="<?php echo esc_url( add_query_arg( 'get-post-lock', '1', wp_nonce_url( get_edit_post_link( $post->ID, 'url' ), 'lock-post_' . $post->ID ) ) ); ?>"><?php _e('Take over'); ?></a> |
|
| 1603 | + <a class="button button-primary wp-tab-last" href="<?php echo esc_url(add_query_arg('get-post-lock', '1', wp_nonce_url(get_edit_post_link($post->ID, 'url'), 'lock-post_'.$post->ID))); ?>"><?php _e('Take over'); ?></a> |
|
| 1604 | 1604 | <?php |
| 1605 | 1605 | } |
| 1606 | 1606 | |
@@ -1614,7 +1614,7 @@ discard block |
||
| 1614 | 1614 | <div class="post-locked-avatar"></div> |
| 1615 | 1615 | <p class="wp-tab-first" tabindex="0"> |
| 1616 | 1616 | <span class="currently-editing"></span><br /> |
| 1617 | - <span class="locked-saving hidden"><img src="<?php echo esc_url( admin_url( 'images/spinner-2x.gif' ) ); ?>" width="16" height="16" alt="" /> <?php _e( 'Saving revision…' ); ?></span> |
|
| 1617 | + <span class="locked-saving hidden"><img src="<?php echo esc_url(admin_url('images/spinner-2x.gif')); ?>" width="16" height="16" alt="" /> <?php _e('Saving revision…'); ?></span> |
|
| 1618 | 1618 | <span class="locked-saved hidden"><?php _e('Your latest changes were saved as a revision.'); ?></span> |
| 1619 | 1619 | </p> |
| 1620 | 1620 | <?php |
@@ -1625,9 +1625,9 @@ discard block |
||
| 1625 | 1625 | * |
| 1626 | 1626 | * @param WP_Post $post Post object. |
| 1627 | 1627 | */ |
| 1628 | - do_action( 'post_lock_lost_dialog', $post ); |
|
| 1628 | + do_action('post_lock_lost_dialog', $post); |
|
| 1629 | 1629 | ?> |
| 1630 | - <p><a class="button button-primary wp-tab-last" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a></p> |
|
| 1630 | + <p><a class="button button-primary wp-tab-last" href="<?php echo esc_url($sendback); ?>"><?php echo $sendback_text; ?></a></p> |
|
| 1631 | 1631 | </div> |
| 1632 | 1632 | <?php |
| 1633 | 1633 | } |
@@ -1648,38 +1648,38 @@ discard block |
||
| 1648 | 1648 | * @param mixed $post_data Associative array containing the post data or int post ID. |
| 1649 | 1649 | * @return mixed The autosave revision ID. WP_Error or 0 on error. |
| 1650 | 1650 | */ |
| 1651 | -function wp_create_post_autosave( $post_data ) { |
|
| 1652 | - if ( is_numeric( $post_data ) ) { |
|
| 1651 | +function wp_create_post_autosave($post_data) { |
|
| 1652 | + if (is_numeric($post_data)) { |
|
| 1653 | 1653 | $post_id = $post_data; |
| 1654 | 1654 | $post_data = $_POST; |
| 1655 | 1655 | } else { |
| 1656 | 1656 | $post_id = (int) $post_data['post_ID']; |
| 1657 | 1657 | } |
| 1658 | 1658 | |
| 1659 | - $post_data = _wp_translate_postdata( true, $post_data ); |
|
| 1660 | - if ( is_wp_error( $post_data ) ) |
|
| 1659 | + $post_data = _wp_translate_postdata(true, $post_data); |
|
| 1660 | + if (is_wp_error($post_data)) |
|
| 1661 | 1661 | return $post_data; |
| 1662 | 1662 | |
| 1663 | 1663 | $post_author = get_current_user_id(); |
| 1664 | 1664 | |
| 1665 | 1665 | // Store one autosave per author. If there is already an autosave, overwrite it. |
| 1666 | - if ( $old_autosave = wp_get_post_autosave( $post_id, $post_author ) ) { |
|
| 1667 | - $new_autosave = _wp_post_revision_data( $post_data, true ); |
|
| 1666 | + if ($old_autosave = wp_get_post_autosave($post_id, $post_author)) { |
|
| 1667 | + $new_autosave = _wp_post_revision_data($post_data, true); |
|
| 1668 | 1668 | $new_autosave['ID'] = $old_autosave->ID; |
| 1669 | 1669 | $new_autosave['post_author'] = $post_author; |
| 1670 | 1670 | |
| 1671 | 1671 | // If the new autosave has the same content as the post, delete the autosave. |
| 1672 | - $post = get_post( $post_id ); |
|
| 1672 | + $post = get_post($post_id); |
|
| 1673 | 1673 | $autosave_is_different = false; |
| 1674 | - foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) { |
|
| 1675 | - if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) { |
|
| 1674 | + foreach (array_intersect(array_keys($new_autosave), array_keys(_wp_post_revision_fields($post))) as $field) { |
|
| 1675 | + if (normalize_whitespace($new_autosave[$field]) != normalize_whitespace($post->$field)) { |
|
| 1676 | 1676 | $autosave_is_different = true; |
| 1677 | 1677 | break; |
| 1678 | 1678 | } |
| 1679 | 1679 | } |
| 1680 | 1680 | |
| 1681 | - if ( ! $autosave_is_different ) { |
|
| 1682 | - wp_delete_post_revision( $old_autosave->ID ); |
|
| 1681 | + if ( ! $autosave_is_different) { |
|
| 1682 | + wp_delete_post_revision($old_autosave->ID); |
|
| 1683 | 1683 | return 0; |
| 1684 | 1684 | } |
| 1685 | 1685 | |
@@ -1690,16 +1690,16 @@ discard block |
||
| 1690 | 1690 | * |
| 1691 | 1691 | * @param array $new_autosave Post array - the autosave that is about to be saved. |
| 1692 | 1692 | */ |
| 1693 | - do_action( 'wp_creating_autosave', $new_autosave ); |
|
| 1693 | + do_action('wp_creating_autosave', $new_autosave); |
|
| 1694 | 1694 | |
| 1695 | - return wp_update_post( $new_autosave ); |
|
| 1695 | + return wp_update_post($new_autosave); |
|
| 1696 | 1696 | } |
| 1697 | 1697 | |
| 1698 | 1698 | // _wp_put_post_revision() expects unescaped. |
| 1699 | - $post_data = wp_unslash( $post_data ); |
|
| 1699 | + $post_data = wp_unslash($post_data); |
|
| 1700 | 1700 | |
| 1701 | 1701 | // Otherwise create the new autosave as a special post revision |
| 1702 | - return _wp_put_post_revision( $post_data, true ); |
|
| 1702 | + return _wp_put_post_revision($post_data, true); |
|
| 1703 | 1703 | } |
| 1704 | 1704 | |
| 1705 | 1705 | /** |
@@ -1715,46 +1715,46 @@ discard block |
||
| 1715 | 1715 | $post_ID = (int) $_POST['post_ID']; |
| 1716 | 1716 | $_POST['ID'] = $post_ID; |
| 1717 | 1717 | |
| 1718 | - if ( ! $post = get_post( $post_ID ) ) { |
|
| 1719 | - wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); |
|
| 1718 | + if ( ! $post = get_post($post_ID)) { |
|
| 1719 | + wp_die(__('Sorry, you are not allowed to edit this post.')); |
|
| 1720 | 1720 | } |
| 1721 | 1721 | |
| 1722 | - if ( ! current_user_can( 'edit_post', $post->ID ) ) { |
|
| 1723 | - wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); |
|
| 1722 | + if ( ! current_user_can('edit_post', $post->ID)) { |
|
| 1723 | + wp_die(__('Sorry, you are not allowed to edit this post.')); |
|
| 1724 | 1724 | } |
| 1725 | 1725 | |
| 1726 | 1726 | $is_autosave = false; |
| 1727 | 1727 | |
| 1728 | - if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'draft' == $post->post_status || 'auto-draft' == $post->post_status ) ) { |
|
| 1728 | + if ( ! wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author && ('draft' == $post->post_status || 'auto-draft' == $post->post_status)) { |
|
| 1729 | 1729 | $saved_post_id = edit_post(); |
| 1730 | 1730 | } else { |
| 1731 | 1731 | $is_autosave = true; |
| 1732 | 1732 | |
| 1733 | - if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) |
|
| 1733 | + if (isset($_POST['post_status']) && 'auto-draft' == $_POST['post_status']) |
|
| 1734 | 1734 | $_POST['post_status'] = 'draft'; |
| 1735 | 1735 | |
| 1736 | - $saved_post_id = wp_create_post_autosave( $post->ID ); |
|
| 1736 | + $saved_post_id = wp_create_post_autosave($post->ID); |
|
| 1737 | 1737 | } |
| 1738 | 1738 | |
| 1739 | - if ( is_wp_error( $saved_post_id ) ) |
|
| 1740 | - wp_die( $saved_post_id->get_error_message() ); |
|
| 1739 | + if (is_wp_error($saved_post_id)) |
|
| 1740 | + wp_die($saved_post_id->get_error_message()); |
|
| 1741 | 1741 | |
| 1742 | 1742 | $query_args = array(); |
| 1743 | 1743 | |
| 1744 | - if ( $is_autosave && $saved_post_id ) { |
|
| 1744 | + if ($is_autosave && $saved_post_id) { |
|
| 1745 | 1745 | $query_args['preview_id'] = $post->ID; |
| 1746 | - $query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID ); |
|
| 1746 | + $query_args['preview_nonce'] = wp_create_nonce('post_preview_'.$post->ID); |
|
| 1747 | 1747 | |
| 1748 | - if ( isset( $_POST['post_format'] ) ) { |
|
| 1749 | - $query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] ); |
|
| 1748 | + if (isset($_POST['post_format'])) { |
|
| 1749 | + $query_args['post_format'] = empty($_POST['post_format']) ? 'standard' : sanitize_key($_POST['post_format']); |
|
| 1750 | 1750 | } |
| 1751 | 1751 | |
| 1752 | - if ( isset( $_POST['_thumbnail_id'] ) ) { |
|
| 1753 | - $query_args['_thumbnail_id'] = ( intval( $_POST['_thumbnail_id'] ) <= 0 ) ? '-1' : intval( $_POST['_thumbnail_id'] ); |
|
| 1752 | + if (isset($_POST['_thumbnail_id'])) { |
|
| 1753 | + $query_args['_thumbnail_id'] = (intval($_POST['_thumbnail_id']) <= 0) ? '-1' : intval($_POST['_thumbnail_id']); |
|
| 1754 | 1754 | } |
| 1755 | 1755 | } |
| 1756 | 1756 | |
| 1757 | - return get_preview_post_link( $post, $query_args ); |
|
| 1757 | + return get_preview_post_link($post, $query_args); |
|
| 1758 | 1758 | } |
| 1759 | 1759 | |
| 1760 | 1760 | /** |
@@ -1768,36 +1768,36 @@ discard block |
||
| 1768 | 1768 | * @return mixed The value 0 or WP_Error on failure. The saved post ID on success. |
| 1769 | 1769 | * The ID can be the draft post_id or the autosave revision post_id. |
| 1770 | 1770 | */ |
| 1771 | -function wp_autosave( $post_data ) { |
|
| 1771 | +function wp_autosave($post_data) { |
|
| 1772 | 1772 | // Back-compat |
| 1773 | - if ( ! defined( 'DOING_AUTOSAVE' ) ) |
|
| 1774 | - define( 'DOING_AUTOSAVE', true ); |
|
| 1773 | + if ( ! defined('DOING_AUTOSAVE')) |
|
| 1774 | + define('DOING_AUTOSAVE', true); |
|
| 1775 | 1775 | |
| 1776 | 1776 | $post_id = (int) $post_data['post_id']; |
| 1777 | 1777 | $post_data['ID'] = $post_data['post_ID'] = $post_id; |
| 1778 | 1778 | |
| 1779 | - if ( false === wp_verify_nonce( $post_data['_wpnonce'], 'update-post_' . $post_id ) ) { |
|
| 1780 | - return new WP_Error( 'invalid_nonce', __( 'Error while saving.' ) ); |
|
| 1779 | + if (false === wp_verify_nonce($post_data['_wpnonce'], 'update-post_'.$post_id)) { |
|
| 1780 | + return new WP_Error('invalid_nonce', __('Error while saving.')); |
|
| 1781 | 1781 | } |
| 1782 | 1782 | |
| 1783 | - $post = get_post( $post_id ); |
|
| 1783 | + $post = get_post($post_id); |
|
| 1784 | 1784 | |
| 1785 | - if ( ! current_user_can( 'edit_post', $post->ID ) ) { |
|
| 1786 | - return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to edit this item.' ) ); |
|
| 1785 | + if ( ! current_user_can('edit_post', $post->ID)) { |
|
| 1786 | + return new WP_Error('edit_posts', __('Sorry, you are not allowed to edit this item.')); |
|
| 1787 | 1787 | } |
| 1788 | 1788 | |
| 1789 | - if ( 'auto-draft' == $post->post_status ) |
|
| 1789 | + if ('auto-draft' == $post->post_status) |
|
| 1790 | 1790 | $post_data['post_status'] = 'draft'; |
| 1791 | 1791 | |
| 1792 | - if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) ) |
|
| 1793 | - $post_data['post_category'] = explode( ',', $post_data['catslist'] ); |
|
| 1792 | + if ($post_data['post_type'] != 'page' && ! empty($post_data['catslist'])) |
|
| 1793 | + $post_data['post_category'] = explode(',', $post_data['catslist']); |
|
| 1794 | 1794 | |
| 1795 | - if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) { |
|
| 1795 | + if ( ! wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author && ('auto-draft' == $post->post_status || 'draft' == $post->post_status)) { |
|
| 1796 | 1796 | // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked |
| 1797 | - return edit_post( wp_slash( $post_data ) ); |
|
| 1797 | + return edit_post(wp_slash($post_data)); |
|
| 1798 | 1798 | } else { |
| 1799 | 1799 | // Non drafts or other users drafts are not overwritten. The autosave is stored in a special post revision for each user. |
| 1800 | - return wp_create_post_autosave( wp_slash( $post_data ) ); |
|
| 1800 | + return wp_create_post_autosave(wp_slash($post_data)); |
|
| 1801 | 1801 | } |
| 1802 | 1802 | } |
| 1803 | 1803 | |
@@ -1807,11 +1807,11 @@ discard block |
||
| 1807 | 1807 | * @param int $post_id Optional. Post ID. |
| 1808 | 1808 | */ |
| 1809 | 1809 | function redirect_post($post_id = '') { |
| 1810 | - if ( isset($_POST['save']) || isset($_POST['publish']) ) { |
|
| 1811 | - $status = get_post_status( $post_id ); |
|
| 1810 | + if (isset($_POST['save']) || isset($_POST['publish'])) { |
|
| 1811 | + $status = get_post_status($post_id); |
|
| 1812 | 1812 | |
| 1813 | - if ( isset( $_POST['publish'] ) ) { |
|
| 1814 | - switch ( $status ) { |
|
| 1813 | + if (isset($_POST['publish'])) { |
|
| 1814 | + switch ($status) { |
|
| 1815 | 1815 | case 'pending': |
| 1816 | 1816 | $message = 8; |
| 1817 | 1817 | break; |
@@ -1825,17 +1825,17 @@ discard block |
||
| 1825 | 1825 | $message = 'draft' == $status ? 10 : 1; |
| 1826 | 1826 | } |
| 1827 | 1827 | |
| 1828 | - $location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) ); |
|
| 1829 | - } elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) { |
|
| 1830 | - $location = add_query_arg( 'message', 2, wp_get_referer() ); |
|
| 1828 | + $location = add_query_arg('message', $message, get_edit_post_link($post_id, 'url')); |
|
| 1829 | + } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) { |
|
| 1830 | + $location = add_query_arg('message', 2, wp_get_referer()); |
|
| 1831 | 1831 | $location = explode('#', $location); |
| 1832 | - $location = $location[0] . '#postcustom'; |
|
| 1833 | - } elseif ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) { |
|
| 1834 | - $location = add_query_arg( 'message', 3, wp_get_referer() ); |
|
| 1832 | + $location = $location[0].'#postcustom'; |
|
| 1833 | + } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) { |
|
| 1834 | + $location = add_query_arg('message', 3, wp_get_referer()); |
|
| 1835 | 1835 | $location = explode('#', $location); |
| 1836 | - $location = $location[0] . '#postcustom'; |
|
| 1836 | + $location = $location[0].'#postcustom'; |
|
| 1837 | 1837 | } else { |
| 1838 | - $location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) ); |
|
| 1838 | + $location = add_query_arg('message', 4, get_edit_post_link($post_id, 'url')); |
|
| 1839 | 1839 | } |
| 1840 | 1840 | |
| 1841 | 1841 | /** |
@@ -1846,6 +1846,6 @@ discard block |
||
| 1846 | 1846 | * @param string $location The destination URL. |
| 1847 | 1847 | * @param int $post_id The post ID. |
| 1848 | 1848 | */ |
| 1849 | - wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) ); |
|
| 1849 | + wp_redirect(apply_filters('redirect_post_location', $location, $post_id)); |
|
| 1850 | 1850 | exit; |
| 1851 | 1851 | } |
@@ -20,37 +20,45 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | function _wp_translate_postdata( $update = false, $post_data = null ) { |
| 22 | 22 | |
| 23 | - if ( empty($post_data) ) |
|
| 24 | - $post_data = &$_POST; |
|
| 23 | + if ( empty($post_data) ) { |
|
| 24 | + $post_data = &$_POST; |
|
| 25 | + } |
|
| 25 | 26 | |
| 26 | - if ( $update ) |
|
| 27 | - $post_data['ID'] = (int) $post_data['post_ID']; |
|
| 27 | + if ( $update ) { |
|
| 28 | + $post_data['ID'] = (int) $post_data['post_ID']; |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | 31 | $ptype = get_post_type_object( $post_data['post_type'] ); |
| 30 | 32 | |
| 31 | 33 | if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) { |
| 32 | - if ( 'page' == $post_data['post_type'] ) |
|
| 33 | - return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); |
|
| 34 | - else |
|
| 35 | - return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); |
|
| 34 | + if ( 'page' == $post_data['post_type'] ) { |
|
| 35 | + return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); |
|
| 36 | + } else { |
|
| 37 | + return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); |
|
| 38 | + } |
|
| 36 | 39 | } elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) { |
| 37 | - if ( 'page' == $post_data['post_type'] ) |
|
| 38 | - return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); |
|
| 39 | - else |
|
| 40 | - return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); |
|
| 40 | + if ( 'page' == $post_data['post_type'] ) { |
|
| 41 | + return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); |
|
| 42 | + } else { |
|
| 43 | + return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); |
|
| 44 | + } |
|
| 41 | 45 | } |
| 42 | 46 | |
| 43 | - if ( isset( $post_data['content'] ) ) |
|
| 44 | - $post_data['post_content'] = $post_data['content']; |
|
| 47 | + if ( isset( $post_data['content'] ) ) { |
|
| 48 | + $post_data['post_content'] = $post_data['content']; |
|
| 49 | + } |
|
| 45 | 50 | |
| 46 | - if ( isset( $post_data['excerpt'] ) ) |
|
| 47 | - $post_data['post_excerpt'] = $post_data['excerpt']; |
|
| 51 | + if ( isset( $post_data['excerpt'] ) ) { |
|
| 52 | + $post_data['post_excerpt'] = $post_data['excerpt']; |
|
| 53 | + } |
|
| 48 | 54 | |
| 49 | - if ( isset( $post_data['parent_id'] ) ) |
|
| 50 | - $post_data['post_parent'] = (int) $post_data['parent_id']; |
|
| 55 | + if ( isset( $post_data['parent_id'] ) ) { |
|
| 56 | + $post_data['post_parent'] = (int) $post_data['parent_id']; |
|
| 57 | + } |
|
| 51 | 58 | |
| 52 | - if ( isset($post_data['trackback_url']) ) |
|
| 53 | - $post_data['to_ping'] = $post_data['trackback_url']; |
|
| 59 | + if ( isset($post_data['trackback_url']) ) { |
|
| 60 | + $post_data['to_ping'] = $post_data['trackback_url']; |
|
| 61 | + } |
|
| 54 | 62 | |
| 55 | 63 | $post_data['user_ID'] = get_current_user_id(); |
| 56 | 64 | |
@@ -67,15 +75,17 @@ discard block |
||
| 67 | 75 | if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] ) |
| 68 | 76 | && ! current_user_can( $ptype->cap->edit_others_posts ) ) { |
| 69 | 77 | if ( $update ) { |
| 70 | - if ( 'page' == $post_data['post_type'] ) |
|
| 71 | - return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); |
|
| 72 | - else |
|
| 73 | - return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); |
|
| 78 | + if ( 'page' == $post_data['post_type'] ) { |
|
| 79 | + return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); |
|
| 80 | + } else { |
|
| 81 | + return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); |
|
| 82 | + } |
|
| 74 | 83 | } else { |
| 75 | - if ( 'page' == $post_data['post_type'] ) |
|
| 76 | - return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); |
|
| 77 | - else |
|
| 78 | - return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); |
|
| 84 | + if ( 'page' == $post_data['post_type'] ) { |
|
| 85 | + return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); |
|
| 86 | + } else { |
|
| 87 | + return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); |
|
| 88 | + } |
|
| 79 | 89 | } |
| 80 | 90 | } |
| 81 | 91 | |
@@ -93,21 +103,27 @@ discard block |
||
| 93 | 103 | } |
| 94 | 104 | |
| 95 | 105 | // What to do based on which button they pressed |
| 96 | - if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) |
|
| 97 | - $post_data['post_status'] = 'draft'; |
|
| 98 | - if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) |
|
| 99 | - $post_data['post_status'] = 'private'; |
|
| 100 | - if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) ) |
|
| 101 | - $post_data['post_status'] = 'publish'; |
|
| 102 | - if ( isset($post_data['advanced']) && '' != $post_data['advanced'] ) |
|
| 103 | - $post_data['post_status'] = 'draft'; |
|
| 104 | - if ( isset($post_data['pending']) && '' != $post_data['pending'] ) |
|
| 105 | - $post_data['post_status'] = 'pending'; |
|
| 106 | - |
|
| 107 | - if ( isset( $post_data['ID'] ) ) |
|
| 108 | - $post_id = $post_data['ID']; |
|
| 109 | - else |
|
| 110 | - $post_id = false; |
|
| 106 | + if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) { |
|
| 107 | + $post_data['post_status'] = 'draft'; |
|
| 108 | + } |
|
| 109 | + if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) { |
|
| 110 | + $post_data['post_status'] = 'private'; |
|
| 111 | + } |
|
| 112 | + if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) ) { |
|
| 113 | + $post_data['post_status'] = 'publish'; |
|
| 114 | + } |
|
| 115 | + if ( isset($post_data['advanced']) && '' != $post_data['advanced'] ) { |
|
| 116 | + $post_data['post_status'] = 'draft'; |
|
| 117 | + } |
|
| 118 | + if ( isset($post_data['pending']) && '' != $post_data['pending'] ) { |
|
| 119 | + $post_data['post_status'] = 'pending'; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + if ( isset( $post_data['ID'] ) ) { |
|
| 123 | + $post_id = $post_data['ID']; |
|
| 124 | + } else { |
|
| 125 | + $post_id = false; |
|
| 126 | + } |
|
| 111 | 127 | $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false; |
| 112 | 128 | |
| 113 | 129 | if ( isset( $post_data['post_status'] ) && 'private' == $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) { |
@@ -118,9 +134,10 @@ discard block |
||
| 118 | 134 | |
| 119 | 135 | // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published. |
| 120 | 136 | // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts. |
| 121 | - if ( isset($post_data['post_status']) && (in_array( $post_data['post_status'], $published_statuses ) && !current_user_can( $ptype->cap->publish_posts )) ) |
|
| 122 | - if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) ) |
|
| 137 | + if ( isset($post_data['post_status']) && (in_array( $post_data['post_status'], $published_statuses ) && !current_user_can( $ptype->cap->publish_posts )) ) { |
|
| 138 | + if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) ) |
|
| 123 | 139 | $post_data['post_status'] = 'pending'; |
| 140 | + } |
|
| 124 | 141 | |
| 125 | 142 | if ( ! isset( $post_data['post_status'] ) ) { |
| 126 | 143 | $post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status; |
@@ -130,11 +147,13 @@ discard block |
||
| 130 | 147 | unset( $post_data['post_password'] ); |
| 131 | 148 | } |
| 132 | 149 | |
| 133 | - if (!isset( $post_data['comment_status'] )) |
|
| 134 | - $post_data['comment_status'] = 'closed'; |
|
| 150 | + if (!isset( $post_data['comment_status'] )) { |
|
| 151 | + $post_data['comment_status'] = 'closed'; |
|
| 152 | + } |
|
| 135 | 153 | |
| 136 | - if (!isset( $post_data['ping_status'] )) |
|
| 137 | - $post_data['ping_status'] = 'closed'; |
|
| 154 | + if (!isset( $post_data['ping_status'] )) { |
|
| 155 | + $post_data['ping_status'] = 'closed'; |
|
| 156 | + } |
|
| 138 | 157 | |
| 139 | 158 | foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { |
| 140 | 159 | if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) { |
@@ -188,8 +207,9 @@ discard block |
||
| 188 | 207 | function edit_post( $post_data = null ) { |
| 189 | 208 | global $wpdb; |
| 190 | 209 | |
| 191 | - if ( empty($post_data) ) |
|
| 192 | - $post_data = &$_POST; |
|
| 210 | + if ( empty($post_data) ) { |
|
| 211 | + $post_data = &$_POST; |
|
| 212 | + } |
|
| 193 | 213 | |
| 194 | 214 | // Clear out any data in internal vars. |
| 195 | 215 | unset( $post_data['filter'] ); |
@@ -209,10 +229,11 @@ discard block |
||
| 209 | 229 | |
| 210 | 230 | $ptype = get_post_type_object($post_data['post_type']); |
| 211 | 231 | if ( !current_user_can( 'edit_post', $post_ID ) ) { |
| 212 | - if ( 'page' == $post_data['post_type'] ) |
|
| 213 | - wp_die( __('Sorry, you are not allowed to edit this page.' )); |
|
| 214 | - else |
|
| 215 | - wp_die( __('Sorry, you are not allowed to edit this post.' )); |
|
| 232 | + if ( 'page' == $post_data['post_type'] ) { |
|
| 233 | + wp_die( __('Sorry, you are not allowed to edit this page.' )); |
|
| 234 | + } else { |
|
| 235 | + wp_die( __('Sorry, you are not allowed to edit this post.' )); |
|
| 236 | + } |
|
| 216 | 237 | } |
| 217 | 238 | |
| 218 | 239 | if ( post_type_supports( $ptype->name, 'revisions' ) ) { |
@@ -220,8 +241,9 @@ discard block |
||
| 220 | 241 | $revision = current( $revisions ); |
| 221 | 242 | |
| 222 | 243 | // Check if the revisions have been upgraded |
| 223 | - if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) |
|
| 224 | - _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); |
|
| 244 | + if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) { |
|
| 245 | + _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); |
|
| 246 | + } |
|
| 225 | 247 | } |
| 226 | 248 | |
| 227 | 249 | if ( isset($post_data['visibility']) ) { |
@@ -241,18 +263,21 @@ discard block |
||
| 241 | 263 | } |
| 242 | 264 | |
| 243 | 265 | $post_data = _wp_translate_postdata( true, $post_data ); |
| 244 | - if ( is_wp_error($post_data) ) |
|
| 245 | - wp_die( $post_data->get_error_message() ); |
|
| 266 | + if ( is_wp_error($post_data) ) { |
|
| 267 | + wp_die( $post_data->get_error_message() ); |
|
| 268 | + } |
|
| 246 | 269 | |
| 247 | 270 | // Post Formats |
| 248 | - if ( isset( $post_data['post_format'] ) ) |
|
| 249 | - set_post_format( $post_ID, $post_data['post_format'] ); |
|
| 271 | + if ( isset( $post_data['post_format'] ) ) { |
|
| 272 | + set_post_format( $post_ID, $post_data['post_format'] ); |
|
| 273 | + } |
|
| 250 | 274 | |
| 251 | 275 | $format_meta_urls = array( 'url', 'link_url', 'quote_source_url' ); |
| 252 | 276 | foreach ( $format_meta_urls as $format_meta_url ) { |
| 253 | 277 | $keyed = '_format_' . $format_meta_url; |
| 254 | - if ( isset( $post_data[ $keyed ] ) ) |
|
| 255 | - update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) ); |
|
| 278 | + if ( isset( $post_data[ $keyed ] ) ) { |
|
| 279 | + update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) ); |
|
| 280 | + } |
|
| 256 | 281 | } |
| 257 | 282 | |
| 258 | 283 | $format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' ); |
@@ -260,10 +285,11 @@ discard block |
||
| 260 | 285 | foreach ( $format_keys as $key ) { |
| 261 | 286 | $keyed = '_format_' . $key; |
| 262 | 287 | if ( isset( $post_data[ $keyed ] ) ) { |
| 263 | - if ( current_user_can( 'unfiltered_html' ) ) |
|
| 264 | - update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] ); |
|
| 265 | - else |
|
| 266 | - update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) ); |
|
| 288 | + if ( current_user_can( 'unfiltered_html' ) ) { |
|
| 289 | + update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] ); |
|
| 290 | + } else { |
|
| 291 | + update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) ); |
|
| 292 | + } |
|
| 267 | 293 | } |
| 268 | 294 | } |
| 269 | 295 | |
@@ -284,24 +310,30 @@ discard block |
||
| 284 | 310 | // Meta Stuff |
| 285 | 311 | if ( isset($post_data['meta']) && $post_data['meta'] ) { |
| 286 | 312 | foreach ( $post_data['meta'] as $key => $value ) { |
| 287 | - if ( !$meta = get_post_meta_by_id( $key ) ) |
|
| 288 | - continue; |
|
| 289 | - if ( $meta->post_id != $post_ID ) |
|
| 290 | - continue; |
|
| 291 | - if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) |
|
| 292 | - continue; |
|
| 313 | + if ( !$meta = get_post_meta_by_id( $key ) ) { |
|
| 314 | + continue; |
|
| 315 | + } |
|
| 316 | + if ( $meta->post_id != $post_ID ) { |
|
| 317 | + continue; |
|
| 318 | + } |
|
| 319 | + if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) { |
|
| 320 | + continue; |
|
| 321 | + } |
|
| 293 | 322 | update_meta( $key, $value['key'], $value['value'] ); |
| 294 | 323 | } |
| 295 | 324 | } |
| 296 | 325 | |
| 297 | 326 | if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) { |
| 298 | 327 | foreach ( $post_data['deletemeta'] as $key => $value ) { |
| 299 | - if ( !$meta = get_post_meta_by_id( $key ) ) |
|
| 300 | - continue; |
|
| 301 | - if ( $meta->post_id != $post_ID ) |
|
| 302 | - continue; |
|
| 303 | - if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) |
|
| 304 | - continue; |
|
| 328 | + if ( !$meta = get_post_meta_by_id( $key ) ) { |
|
| 329 | + continue; |
|
| 330 | + } |
|
| 331 | + if ( $meta->post_id != $post_ID ) { |
|
| 332 | + continue; |
|
| 333 | + } |
|
| 334 | + if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) { |
|
| 335 | + continue; |
|
| 336 | + } |
|
| 305 | 337 | delete_meta( $key ); |
| 306 | 338 | } |
| 307 | 339 | } |
@@ -393,10 +425,11 @@ discard block |
||
| 393 | 425 | wp_set_post_lock( $post_ID ); |
| 394 | 426 | |
| 395 | 427 | if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) { |
| 396 | - if ( ! empty( $post_data['sticky'] ) ) |
|
| 397 | - stick_post( $post_ID ); |
|
| 398 | - else |
|
| 399 | - unstick_post( $post_ID ); |
|
| 428 | + if ( ! empty( $post_data['sticky'] ) ) { |
|
| 429 | + stick_post( $post_ID ); |
|
| 430 | + } else { |
|
| 431 | + unstick_post( $post_ID ); |
|
| 432 | + } |
|
| 400 | 433 | } |
| 401 | 434 | |
| 402 | 435 | return $post_ID; |
@@ -418,19 +451,22 @@ discard block |
||
| 418 | 451 | function bulk_edit_posts( $post_data = null ) { |
| 419 | 452 | global $wpdb; |
| 420 | 453 | |
| 421 | - if ( empty($post_data) ) |
|
| 422 | - $post_data = &$_POST; |
|
| 454 | + if ( empty($post_data) ) { |
|
| 455 | + $post_data = &$_POST; |
|
| 456 | + } |
|
| 423 | 457 | |
| 424 | - if ( isset($post_data['post_type']) ) |
|
| 425 | - $ptype = get_post_type_object($post_data['post_type']); |
|
| 426 | - else |
|
| 427 | - $ptype = get_post_type_object('post'); |
|
| 458 | + if ( isset($post_data['post_type']) ) { |
|
| 459 | + $ptype = get_post_type_object($post_data['post_type']); |
|
| 460 | + } else { |
|
| 461 | + $ptype = get_post_type_object('post'); |
|
| 462 | + } |
|
| 428 | 463 | |
| 429 | 464 | if ( !current_user_can( $ptype->cap->edit_posts ) ) { |
| 430 | - if ( 'page' == $ptype->name ) |
|
| 431 | - wp_die( __('Sorry, you are not allowed to edit pages.')); |
|
| 432 | - else |
|
| 433 | - wp_die( __('Sorry, you are not allowed to edit posts.')); |
|
| 465 | + if ( 'page' == $ptype->name ) { |
|
| 466 | + wp_die( __('Sorry, you are not allowed to edit pages.')); |
|
| 467 | + } else { |
|
| 468 | + wp_die( __('Sorry, you are not allowed to edit posts.')); |
|
| 469 | + } |
|
| 434 | 470 | } |
| 435 | 471 | |
| 436 | 472 | if ( -1 == $post_data['_status'] ) { |
@@ -459,28 +495,32 @@ discard block |
||
| 459 | 495 | ); |
| 460 | 496 | |
| 461 | 497 | foreach ( $reset as $field ) { |
| 462 | - if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) |
|
| 463 | - unset($post_data[$field]); |
|
| 498 | + if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) { |
|
| 499 | + unset($post_data[$field]); |
|
| 500 | + } |
|
| 464 | 501 | } |
| 465 | 502 | |
| 466 | 503 | if ( isset($post_data['post_category']) ) { |
| 467 | - if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) ) |
|
| 468 | - $new_cats = array_map( 'absint', $post_data['post_category'] ); |
|
| 469 | - else |
|
| 470 | - unset($post_data['post_category']); |
|
| 504 | + if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) ) { |
|
| 505 | + $new_cats = array_map( 'absint', $post_data['post_category'] ); |
|
| 506 | + } else { |
|
| 507 | + unset($post_data['post_category']); |
|
| 508 | + } |
|
| 471 | 509 | } |
| 472 | 510 | |
| 473 | 511 | $tax_input = array(); |
| 474 | 512 | if ( isset($post_data['tax_input'])) { |
| 475 | 513 | foreach ( $post_data['tax_input'] as $tax_name => $terms ) { |
| 476 | - if ( empty($terms) ) |
|
| 477 | - continue; |
|
| 514 | + if ( empty($terms) ) { |
|
| 515 | + continue; |
|
| 516 | + } |
|
| 478 | 517 | if ( is_taxonomy_hierarchical( $tax_name ) ) { |
| 479 | 518 | $tax_input[ $tax_name ] = array_map( 'absint', $terms ); |
| 480 | 519 | } else { |
| 481 | 520 | $comma = _x( ',', 'tag delimiter' ); |
| 482 | - if ( ',' !== $comma ) |
|
| 483 | - $terms = str_replace( $comma, ',', $terms ); |
|
| 521 | + if ( ',' !== $comma ) { |
|
| 522 | + $terms = str_replace( $comma, ',', $terms ); |
|
| 523 | + } |
|
| 484 | 524 | $tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); |
| 485 | 525 | } |
| 486 | 526 | } |
@@ -525,15 +565,17 @@ discard block |
||
| 525 | 565 | $tax_names = get_object_taxonomies( $post ); |
| 526 | 566 | foreach ( $tax_names as $tax_name ) { |
| 527 | 567 | $taxonomy_obj = get_taxonomy($tax_name); |
| 528 | - if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) |
|
| 529 | - $new_terms = $tax_input[$tax_name]; |
|
| 530 | - else |
|
| 531 | - $new_terms = array(); |
|
| 568 | + if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) { |
|
| 569 | + $new_terms = $tax_input[$tax_name]; |
|
| 570 | + } else { |
|
| 571 | + $new_terms = array(); |
|
| 572 | + } |
|
| 532 | 573 | |
| 533 | - if ( $taxonomy_obj->hierarchical ) |
|
| 534 | - $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') ); |
|
| 535 | - else |
|
| 536 | - $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') ); |
|
| 574 | + if ( $taxonomy_obj->hierarchical ) { |
|
| 575 | + $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') ); |
|
| 576 | + } else { |
|
| 577 | + $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') ); |
|
| 578 | + } |
|
| 537 | 579 | |
| 538 | 580 | $post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms ); |
| 539 | 581 | } |
@@ -566,14 +608,16 @@ discard block |
||
| 566 | 608 | $updated[] = wp_update_post( $post_data ); |
| 567 | 609 | |
| 568 | 610 | if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) { |
| 569 | - if ( 'sticky' == $post_data['sticky'] ) |
|
| 570 | - stick_post( $post_ID ); |
|
| 571 | - else |
|
| 572 | - unstick_post( $post_ID ); |
|
| 611 | + if ( 'sticky' == $post_data['sticky'] ) { |
|
| 612 | + stick_post( $post_ID ); |
|
| 613 | + } else { |
|
| 614 | + unstick_post( $post_ID ); |
|
| 615 | + } |
|
| 573 | 616 | } |
| 574 | 617 | |
| 575 | - if ( isset( $post_data['post_format'] ) ) |
|
| 576 | - set_post_format( $post_ID, $post_data['post_format'] ); |
|
| 618 | + if ( isset( $post_data['post_format'] ) ) { |
|
| 619 | + set_post_format( $post_ID, $post_data['post_format'] ); |
|
| 620 | + } |
|
| 577 | 621 | } |
| 578 | 622 | |
| 579 | 623 | return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked ); |
@@ -590,22 +634,26 @@ discard block |
||
| 590 | 634 | */ |
| 591 | 635 | function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { |
| 592 | 636 | $post_title = ''; |
| 593 | - if ( !empty( $_REQUEST['post_title'] ) ) |
|
| 594 | - $post_title = esc_html( wp_unslash( $_REQUEST['post_title'] )); |
|
| 637 | + if ( !empty( $_REQUEST['post_title'] ) ) { |
|
| 638 | + $post_title = esc_html( wp_unslash( $_REQUEST['post_title'] )); |
|
| 639 | + } |
|
| 595 | 640 | |
| 596 | 641 | $post_content = ''; |
| 597 | - if ( !empty( $_REQUEST['content'] ) ) |
|
| 598 | - $post_content = esc_html( wp_unslash( $_REQUEST['content'] )); |
|
| 642 | + if ( !empty( $_REQUEST['content'] ) ) { |
|
| 643 | + $post_content = esc_html( wp_unslash( $_REQUEST['content'] )); |
|
| 644 | + } |
|
| 599 | 645 | |
| 600 | 646 | $post_excerpt = ''; |
| 601 | - if ( !empty( $_REQUEST['excerpt'] ) ) |
|
| 602 | - $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] )); |
|
| 647 | + if ( !empty( $_REQUEST['excerpt'] ) ) { |
|
| 648 | + $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] )); |
|
| 649 | + } |
|
| 603 | 650 | |
| 604 | 651 | if ( $create_in_db ) { |
| 605 | 652 | $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); |
| 606 | 653 | $post = get_post( $post_id ); |
| 607 | - if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) |
|
| 608 | - set_post_format( $post, get_option( 'default_post_format' ) ); |
|
| 654 | + if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) { |
|
| 655 | + set_post_format( $post, get_option( 'default_post_format' ) ); |
|
| 656 | + } |
|
| 609 | 657 | } else { |
| 610 | 658 | $post = new stdClass; |
| 611 | 659 | $post->ID = 0; |
@@ -698,8 +746,9 @@ discard block |
||
| 698 | 746 | $args[] = $post_content; |
| 699 | 747 | } |
| 700 | 748 | |
| 701 | - if ( !empty ( $args ) ) |
|
| 702 | - return (int) $wpdb->get_var( $wpdb->prepare($query, $args) ); |
|
| 749 | + if ( !empty ( $args ) ) { |
|
| 750 | + return (int) $wpdb->get_var( $wpdb->prepare($query, $args) ); |
|
| 751 | + } |
|
| 703 | 752 | |
| 704 | 753 | return 0; |
| 705 | 754 | } |
@@ -714,16 +763,18 @@ discard block |
||
| 714 | 763 | * @return int|WP_Error |
| 715 | 764 | */ |
| 716 | 765 | function wp_write_post() { |
| 717 | - if ( isset($_POST['post_type']) ) |
|
| 718 | - $ptype = get_post_type_object($_POST['post_type']); |
|
| 719 | - else |
|
| 720 | - $ptype = get_post_type_object('post'); |
|
| 766 | + if ( isset($_POST['post_type']) ) { |
|
| 767 | + $ptype = get_post_type_object($_POST['post_type']); |
|
| 768 | + } else { |
|
| 769 | + $ptype = get_post_type_object('post'); |
|
| 770 | + } |
|
| 721 | 771 | |
| 722 | 772 | if ( !current_user_can( $ptype->cap->edit_posts ) ) { |
| 723 | - if ( 'page' == $ptype->name ) |
|
| 724 | - return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) ); |
|
| 725 | - else |
|
| 726 | - return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to create posts or drafts on this site.' ) ); |
|
| 773 | + if ( 'page' == $ptype->name ) { |
|
| 774 | + return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) ); |
|
| 775 | + } else { |
|
| 776 | + return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to create posts or drafts on this site.' ) ); |
|
| 777 | + } |
|
| 727 | 778 | } |
| 728 | 779 | |
| 729 | 780 | $_POST['post_mime_type'] = ''; |
@@ -732,8 +783,9 @@ discard block |
||
| 732 | 783 | unset( $_POST['filter'] ); |
| 733 | 784 | |
| 734 | 785 | // Edit don't write if we have a post id. |
| 735 | - if ( isset( $_POST['post_ID'] ) ) |
|
| 736 | - return edit_post(); |
|
| 786 | + if ( isset( $_POST['post_ID'] ) ) { |
|
| 787 | + return edit_post(); |
|
| 788 | + } |
|
| 737 | 789 | |
| 738 | 790 | if ( isset($_POST['visibility']) ) { |
| 739 | 791 | switch ( $_POST['visibility'] ) { |
@@ -752,16 +804,19 @@ discard block |
||
| 752 | 804 | } |
| 753 | 805 | |
| 754 | 806 | $translated = _wp_translate_postdata( false ); |
| 755 | - if ( is_wp_error($translated) ) |
|
| 756 | - return $translated; |
|
| 807 | + if ( is_wp_error($translated) ) { |
|
| 808 | + return $translated; |
|
| 809 | + } |
|
| 757 | 810 | |
| 758 | 811 | // Create the post. |
| 759 | 812 | $post_ID = wp_insert_post( $_POST ); |
| 760 | - if ( is_wp_error( $post_ID ) ) |
|
| 761 | - return $post_ID; |
|
| 813 | + if ( is_wp_error( $post_ID ) ) { |
|
| 814 | + return $post_ID; |
|
| 815 | + } |
|
| 762 | 816 | |
| 763 | - if ( empty($post_ID) ) |
|
| 764 | - return 0; |
|
| 817 | + if ( empty($post_ID) ) { |
|
| 818 | + return 0; |
|
| 819 | + } |
|
| 765 | 820 | |
| 766 | 821 | add_meta( $post_ID ); |
| 767 | 822 | |
@@ -784,11 +839,12 @@ discard block |
||
| 784 | 839 | */ |
| 785 | 840 | function write_post() { |
| 786 | 841 | $result = wp_write_post(); |
| 787 | - if ( is_wp_error( $result ) ) |
|
| 788 | - wp_die( $result->get_error_message() ); |
|
| 789 | - else |
|
| 790 | - return $result; |
|
| 791 | -} |
|
| 842 | + if ( is_wp_error( $result ) ) { |
|
| 843 | + wp_die( $result->get_error_message() ); |
|
| 844 | + } else { |
|
| 845 | + return $result; |
|
| 846 | + } |
|
| 847 | + } |
|
| 792 | 848 | |
| 793 | 849 | // |
| 794 | 850 | // Post Meta |
@@ -808,22 +864,27 @@ discard block |
||
| 808 | 864 | $metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : ''; |
| 809 | 865 | $metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : ''; |
| 810 | 866 | $metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : ''; |
| 811 | - if ( is_string( $metavalue ) ) |
|
| 812 | - $metavalue = trim( $metavalue ); |
|
| 867 | + if ( is_string( $metavalue ) ) { |
|
| 868 | + $metavalue = trim( $metavalue ); |
|
| 869 | + } |
|
| 813 | 870 | |
| 814 | 871 | if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput ) ) ) { |
| 815 | 872 | /* |
| 816 | 873 | * We have a key/value pair. If both the select and the input |
| 817 | 874 | * for the key have data, the input takes precedence. |
| 818 | 875 | */ |
| 819 | - if ( '#NONE#' != $metakeyselect ) |
|
| 820 | - $metakey = $metakeyselect; |
|
| 876 | + if ( '#NONE#' != $metakeyselect ) { |
|
| 877 | + $metakey = $metakeyselect; |
|
| 878 | + } |
|
| 821 | 879 | |
| 822 | - if ( $metakeyinput ) |
|
| 823 | - $metakey = $metakeyinput; // default |
|
| 880 | + if ( $metakeyinput ) { |
|
| 881 | + $metakey = $metakeyinput; |
|
| 882 | + } |
|
| 883 | + // default |
|
| 824 | 884 | |
| 825 | - if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) |
|
| 826 | - return false; |
|
| 885 | + if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) { |
|
| 886 | + return false; |
|
| 887 | + } |
|
| 827 | 888 | |
| 828 | 889 | $metakey = wp_slash( $metakey ); |
| 829 | 890 | |
@@ -931,12 +992,14 @@ discard block |
||
| 931 | 992 | $content = $post['post_content']; |
| 932 | 993 | |
| 933 | 994 | // Don't run if no pretty permalinks or post is not published, scheduled, or privately published. |
| 934 | - if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) |
|
| 935 | - return; |
|
| 995 | + if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) { |
|
| 996 | + return; |
|
| 997 | + } |
|
| 936 | 998 | |
| 937 | 999 | // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero) |
| 938 | - if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) |
|
| 939 | - return; |
|
| 1000 | + if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) { |
|
| 1001 | + return; |
|
| 1002 | + } |
|
| 940 | 1003 | |
| 941 | 1004 | $site_url = get_bloginfo('url'); |
| 942 | 1005 | $site_url = substr( $site_url, (int) strpos($site_url, '://') ); // remove the http(s) |
@@ -945,15 +1008,17 @@ discard block |
||
| 945 | 1008 | foreach ( $link_matches[1] as $key => $value ) { |
| 946 | 1009 | if ( !strpos($value, '?attachment_id=') || !strpos($value, 'wp-att-') |
| 947 | 1010 | || !preg_match( '/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match ) |
| 948 | - || !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) ) |
|
| 949 | - continue; |
|
| 1011 | + || !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) ) { |
|
| 1012 | + continue; |
|
| 1013 | + } |
|
| 950 | 1014 | |
| 951 | 1015 | $quote = $url_match[1]; // the quote (single or double) |
| 952 | 1016 | $url_id = (int) $url_match[2]; |
| 953 | 1017 | $rel_id = (int) $rel_match[1]; |
| 954 | 1018 | |
| 955 | - if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false ) |
|
| 956 | - continue; |
|
| 1019 | + if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false ) { |
|
| 1020 | + continue; |
|
| 1021 | + } |
|
| 957 | 1022 | |
| 958 | 1023 | $link = $link_matches[0][$key]; |
| 959 | 1024 | $replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote, $link ); |
@@ -993,16 +1058,18 @@ discard block |
||
| 993 | 1058 | * @return array |
| 994 | 1059 | */ |
| 995 | 1060 | function wp_edit_posts_query( $q = false ) { |
| 996 | - if ( false === $q ) |
|
| 997 | - $q = $_GET; |
|
| 1061 | + if ( false === $q ) { |
|
| 1062 | + $q = $_GET; |
|
| 1063 | + } |
|
| 998 | 1064 | $q['m'] = isset($q['m']) ? (int) $q['m'] : 0; |
| 999 | 1065 | $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; |
| 1000 | 1066 | $post_stati = get_post_stati(); |
| 1001 | 1067 | |
| 1002 | - if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) ) |
|
| 1003 | - $post_type = $q['post_type']; |
|
| 1004 | - else |
|
| 1005 | - $post_type = 'post'; |
|
| 1068 | + if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) ) { |
|
| 1069 | + $post_type = $q['post_type']; |
|
| 1070 | + } else { |
|
| 1071 | + $post_type = 'post'; |
|
| 1072 | + } |
|
| 1006 | 1073 | |
| 1007 | 1074 | $avail_post_stati = get_available_post_statuses($post_type); |
| 1008 | 1075 | |
@@ -1025,8 +1092,9 @@ discard block |
||
| 1025 | 1092 | |
| 1026 | 1093 | $per_page = "edit_{$post_type}_per_page"; |
| 1027 | 1094 | $posts_per_page = (int) get_user_option( $per_page ); |
| 1028 | - if ( empty( $posts_per_page ) || $posts_per_page < 1 ) |
|
| 1029 | - $posts_per_page = 20; |
|
| 1095 | + if ( empty( $posts_per_page ) || $posts_per_page < 1 ) { |
|
| 1096 | + $posts_per_page = 20; |
|
| 1097 | + } |
|
| 1030 | 1098 | |
| 1031 | 1099 | /** |
| 1032 | 1100 | * Filters the number of items per page to show for a specific 'per_page' type. |
@@ -1064,8 +1132,9 @@ discard block |
||
| 1064 | 1132 | $query['fields'] = 'id=>parent'; |
| 1065 | 1133 | } |
| 1066 | 1134 | |
| 1067 | - if ( ! empty( $q['show_sticky'] ) ) |
|
| 1068 | - $query['post__in'] = (array) get_option( 'sticky_posts' ); |
|
| 1135 | + if ( ! empty( $q['show_sticky'] ) ) { |
|
| 1136 | + $query['post__in'] = (array) get_option( 'sticky_posts' ); |
|
| 1137 | + } |
|
| 1069 | 1138 | |
| 1070 | 1139 | wp( $query ); |
| 1071 | 1140 | |
@@ -1213,8 +1282,9 @@ discard block |
||
| 1213 | 1282 | */ |
| 1214 | 1283 | function get_sample_permalink($id, $title = null, $name = null) { |
| 1215 | 1284 | $post = get_post( $id ); |
| 1216 | - if ( ! $post ) |
|
| 1217 | - return array( '', '' ); |
|
| 1285 | + if ( ! $post ) { |
|
| 1286 | + return array( '', '' ); |
|
| 1287 | + } |
|
| 1218 | 1288 | |
| 1219 | 1289 | $ptype = get_post_type_object($post->post_type); |
| 1220 | 1290 | |
@@ -1230,8 +1300,9 @@ discard block |
||
| 1230 | 1300 | |
| 1231 | 1301 | // If the user wants to set a new name -- override the current one |
| 1232 | 1302 | // Note: if empty name is supplied -- use the title instead, see #6072 |
| 1233 | - if ( !is_null($name) ) |
|
| 1234 | - $post->post_name = sanitize_title($name ? $name : $title, $post->ID); |
|
| 1303 | + if ( !is_null($name) ) { |
|
| 1304 | + $post->post_name = sanitize_title($name ? $name : $title, $post->ID); |
|
| 1305 | + } |
|
| 1235 | 1306 | |
| 1236 | 1307 | $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent); |
| 1237 | 1308 | |
@@ -1253,8 +1324,9 @@ discard block |
||
| 1253 | 1324 | |
| 1254 | 1325 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
| 1255 | 1326 | $uri = apply_filters( 'editable_slug', $uri, $post ); |
| 1256 | - if ( !empty($uri) ) |
|
| 1257 | - $uri .= '/'; |
|
| 1327 | + if ( !empty($uri) ) { |
|
| 1328 | + $uri .= '/'; |
|
| 1329 | + } |
|
| 1258 | 1330 | $permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink); |
| 1259 | 1331 | } |
| 1260 | 1332 | |
@@ -1291,8 +1363,9 @@ discard block |
||
| 1291 | 1363 | */ |
| 1292 | 1364 | function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { |
| 1293 | 1365 | $post = get_post( $id ); |
| 1294 | - if ( ! $post ) |
|
| 1295 | - return ''; |
|
| 1366 | + if ( ! $post ) { |
|
| 1367 | + return ''; |
|
| 1368 | + } |
|
| 1296 | 1369 | |
| 1297 | 1370 | list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); |
| 1298 | 1371 | |
@@ -1447,11 +1520,13 @@ discard block |
||
| 1447 | 1520 | * @return integer False: not locked or locked by current user. Int: user ID of user with lock. |
| 1448 | 1521 | */ |
| 1449 | 1522 | function wp_check_post_lock( $post_id ) { |
| 1450 | - if ( !$post = get_post( $post_id ) ) |
|
| 1451 | - return false; |
|
| 1523 | + if ( !$post = get_post( $post_id ) ) { |
|
| 1524 | + return false; |
|
| 1525 | + } |
|
| 1452 | 1526 | |
| 1453 | - if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) |
|
| 1454 | - return false; |
|
| 1527 | + if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) { |
|
| 1528 | + return false; |
|
| 1529 | + } |
|
| 1455 | 1530 | |
| 1456 | 1531 | $lock = explode( ':', $lock ); |
| 1457 | 1532 | $time = $lock[0]; |
@@ -1460,8 +1535,9 @@ discard block |
||
| 1460 | 1535 | /** This filter is documented in wp-admin/includes/ajax-actions.php */ |
| 1461 | 1536 | $time_window = apply_filters( 'wp_check_post_lock_window', 150 ); |
| 1462 | 1537 | |
| 1463 | - if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) |
|
| 1464 | - return $user; |
|
| 1538 | + if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) { |
|
| 1539 | + return $user; |
|
| 1540 | + } |
|
| 1465 | 1541 | return false; |
| 1466 | 1542 | } |
| 1467 | 1543 | |
@@ -1475,10 +1551,12 @@ discard block |
||
| 1475 | 1551 | * an array of the lock time and the user ID. |
| 1476 | 1552 | */ |
| 1477 | 1553 | function wp_set_post_lock( $post_id ) { |
| 1478 | - if ( !$post = get_post( $post_id ) ) |
|
| 1479 | - return false; |
|
| 1480 | - if ( 0 == ($user_id = get_current_user_id()) ) |
|
| 1481 | - return false; |
|
| 1554 | + if ( !$post = get_post( $post_id ) ) { |
|
| 1555 | + return false; |
|
| 1556 | + } |
|
| 1557 | + if ( 0 == ($user_id = get_current_user_id()) ) { |
|
| 1558 | + return false; |
|
| 1559 | + } |
|
| 1482 | 1560 | |
| 1483 | 1561 | $now = time(); |
| 1484 | 1562 | $lock = "$now:$user_id"; |
@@ -1494,12 +1572,14 @@ discard block |
||
| 1494 | 1572 | * @return none |
| 1495 | 1573 | */ |
| 1496 | 1574 | function _admin_notice_post_locked() { |
| 1497 | - if ( ! $post = get_post() ) |
|
| 1498 | - return; |
|
| 1575 | + if ( ! $post = get_post() ) { |
|
| 1576 | + return; |
|
| 1577 | + } |
|
| 1499 | 1578 | |
| 1500 | 1579 | $user = null; |
| 1501 | - if ( $user_id = wp_check_post_lock( $post->ID ) ) |
|
| 1502 | - $user = get_userdata( $user_id ); |
|
| 1580 | + if ( $user_id = wp_check_post_lock( $post->ID ) ) { |
|
| 1581 | + $user = get_userdata( $user_id ); |
|
| 1582 | + } |
|
| 1503 | 1583 | |
| 1504 | 1584 | if ( $user ) { |
| 1505 | 1585 | |
@@ -1513,8 +1593,9 @@ discard block |
||
| 1513 | 1593 | * @param bool $display Whether to display the dialog. Default true. |
| 1514 | 1594 | * @param WP_User|bool $user WP_User object on success, false otherwise. |
| 1515 | 1595 | */ |
| 1516 | - if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) |
|
| 1517 | - return; |
|
| 1596 | + if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) { |
|
| 1597 | + return; |
|
| 1598 | + } |
|
| 1518 | 1599 | |
| 1519 | 1600 | $locked = true; |
| 1520 | 1601 | } else { |
@@ -1528,8 +1609,9 @@ discard block |
||
| 1528 | 1609 | } else { |
| 1529 | 1610 | $sendback = admin_url( 'edit.php' ); |
| 1530 | 1611 | |
| 1531 | - if ( 'post' != $post->post_type ) |
|
| 1532 | - $sendback = add_query_arg( 'post_type', $post->post_type, $sendback ); |
|
| 1612 | + if ( 'post' != $post->post_type ) { |
|
| 1613 | + $sendback = add_query_arg( 'post_type', $post->post_type, $sendback ); |
|
| 1614 | + } |
|
| 1533 | 1615 | |
| 1534 | 1616 | $sendback_text = get_post_type_object( $post->post_type )->labels->all_items; |
| 1535 | 1617 | } |
@@ -1576,8 +1658,9 @@ discard block |
||
| 1576 | 1658 | <p class="currently-editing wp-tab-first" tabindex="0"> |
| 1577 | 1659 | <?php |
| 1578 | 1660 | _e( 'This content is currently locked.' ); |
| 1579 | - if ( $override ) |
|
| 1580 | - printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) ); |
|
| 1661 | + if ( $override ) { |
|
| 1662 | + printf( ' ' . __( 'If you take over, %s will be blocked from continuing to edit.' ), esc_html( $user->display_name ) ); |
|
| 1663 | + } |
|
| 1581 | 1664 | ?> |
| 1582 | 1665 | </p> |
| 1583 | 1666 | <?php |
@@ -1657,8 +1740,9 @@ discard block |
||
| 1657 | 1740 | } |
| 1658 | 1741 | |
| 1659 | 1742 | $post_data = _wp_translate_postdata( true, $post_data ); |
| 1660 | - if ( is_wp_error( $post_data ) ) |
|
| 1661 | - return $post_data; |
|
| 1743 | + if ( is_wp_error( $post_data ) ) { |
|
| 1744 | + return $post_data; |
|
| 1745 | + } |
|
| 1662 | 1746 | |
| 1663 | 1747 | $post_author = get_current_user_id(); |
| 1664 | 1748 | |
@@ -1730,14 +1814,16 @@ discard block |
||
| 1730 | 1814 | } else { |
| 1731 | 1815 | $is_autosave = true; |
| 1732 | 1816 | |
| 1733 | - if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) |
|
| 1734 | - $_POST['post_status'] = 'draft'; |
|
| 1817 | + if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) { |
|
| 1818 | + $_POST['post_status'] = 'draft'; |
|
| 1819 | + } |
|
| 1735 | 1820 | |
| 1736 | 1821 | $saved_post_id = wp_create_post_autosave( $post->ID ); |
| 1737 | 1822 | } |
| 1738 | 1823 | |
| 1739 | - if ( is_wp_error( $saved_post_id ) ) |
|
| 1740 | - wp_die( $saved_post_id->get_error_message() ); |
|
| 1824 | + if ( is_wp_error( $saved_post_id ) ) { |
|
| 1825 | + wp_die( $saved_post_id->get_error_message() ); |
|
| 1826 | + } |
|
| 1741 | 1827 | |
| 1742 | 1828 | $query_args = array(); |
| 1743 | 1829 | |
@@ -1770,8 +1856,9 @@ discard block |
||
| 1770 | 1856 | */ |
| 1771 | 1857 | function wp_autosave( $post_data ) { |
| 1772 | 1858 | // Back-compat |
| 1773 | - if ( ! defined( 'DOING_AUTOSAVE' ) ) |
|
| 1774 | - define( 'DOING_AUTOSAVE', true ); |
|
| 1859 | + if ( ! defined( 'DOING_AUTOSAVE' ) ) { |
|
| 1860 | + define( 'DOING_AUTOSAVE', true ); |
|
| 1861 | + } |
|
| 1775 | 1862 | |
| 1776 | 1863 | $post_id = (int) $post_data['post_id']; |
| 1777 | 1864 | $post_data['ID'] = $post_data['post_ID'] = $post_id; |
@@ -1786,11 +1873,13 @@ discard block |
||
| 1786 | 1873 | return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to edit this item.' ) ); |
| 1787 | 1874 | } |
| 1788 | 1875 | |
| 1789 | - if ( 'auto-draft' == $post->post_status ) |
|
| 1790 | - $post_data['post_status'] = 'draft'; |
|
| 1876 | + if ( 'auto-draft' == $post->post_status ) { |
|
| 1877 | + $post_data['post_status'] = 'draft'; |
|
| 1878 | + } |
|
| 1791 | 1879 | |
| 1792 | - if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) ) |
|
| 1793 | - $post_data['post_category'] = explode( ',', $post_data['catslist'] ); |
|
| 1880 | + if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) ) { |
|
| 1881 | + $post_data['post_category'] = explode( ',', $post_data['catslist'] ); |
|
| 1882 | + } |
|
| 1794 | 1883 | |
| 1795 | 1884 | if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) { |
| 1796 | 1885 | // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @access protected |
| 94 | 94 | * @var array |
| 95 | 95 | */ |
| 96 | - protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' ); |
|
| 96 | + protected $compat_fields = array('_args', '_pagination_args', 'screen', '_actions', '_pagination'); |
|
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * {@internal Missing Summary} |
@@ -101,10 +101,10 @@ discard block |
||
| 101 | 101 | * @access protected |
| 102 | 102 | * @var array |
| 103 | 103 | */ |
| 104 | - protected $compat_methods = array( 'set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions', |
|
| 104 | + protected $compat_methods = array('set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions', |
|
| 105 | 105 | 'row_actions', 'months_dropdown', 'view_switcher', 'comments_bubble', 'get_items_per_page', 'pagination', |
| 106 | 106 | 'get_sortable_columns', 'get_column_info', 'get_table_classes', 'display_tablenav', 'extra_tablenav', |
| 107 | - 'single_row_columns' ); |
|
| 107 | + 'single_row_columns'); |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * Constructor. |
@@ -132,35 +132,35 @@ discard block |
||
| 132 | 132 | * Default null. |
| 133 | 133 | * } |
| 134 | 134 | */ |
| 135 | - public function __construct( $args = array() ) { |
|
| 136 | - $args = wp_parse_args( $args, array( |
|
| 135 | + public function __construct($args = array()) { |
|
| 136 | + $args = wp_parse_args($args, array( |
|
| 137 | 137 | 'plural' => '', |
| 138 | 138 | 'singular' => '', |
| 139 | 139 | 'ajax' => false, |
| 140 | 140 | 'screen' => null, |
| 141 | - ) ); |
|
| 141 | + )); |
|
| 142 | 142 | |
| 143 | - $this->screen = convert_to_screen( $args['screen'] ); |
|
| 143 | + $this->screen = convert_to_screen($args['screen']); |
|
| 144 | 144 | |
| 145 | - add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 ); |
|
| 145 | + add_filter("manage_{$this->screen->id}_columns", array($this, 'get_columns'), 0); |
|
| 146 | 146 | |
| 147 | - if ( !$args['plural'] ) |
|
| 147 | + if ( ! $args['plural']) |
|
| 148 | 148 | $args['plural'] = $this->screen->base; |
| 149 | 149 | |
| 150 | - $args['plural'] = sanitize_key( $args['plural'] ); |
|
| 151 | - $args['singular'] = sanitize_key( $args['singular'] ); |
|
| 150 | + $args['plural'] = sanitize_key($args['plural']); |
|
| 151 | + $args['singular'] = sanitize_key($args['singular']); |
|
| 152 | 152 | |
| 153 | 153 | $this->_args = $args; |
| 154 | 154 | |
| 155 | - if ( $args['ajax'] ) { |
|
| 155 | + if ($args['ajax']) { |
|
| 156 | 156 | // wp_enqueue_script( 'list-table' ); |
| 157 | - add_action( 'admin_footer', array( $this, '_js_vars' ) ); |
|
| 157 | + add_action('admin_footer', array($this, '_js_vars')); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if ( empty( $this->modes ) ) { |
|
| 160 | + if (empty($this->modes)) { |
|
| 161 | 161 | $this->modes = array( |
| 162 | - 'list' => __( 'List View' ), |
|
| 163 | - 'excerpt' => __( 'Excerpt View' ) |
|
| 162 | + 'list' => __('List View'), |
|
| 163 | + 'excerpt' => __('Excerpt View') |
|
| 164 | 164 | ); |
| 165 | 165 | } |
| 166 | 166 | } |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | * @param string $name Property to get. |
| 175 | 175 | * @return mixed Property. |
| 176 | 176 | */ |
| 177 | - public function __get( $name ) { |
|
| 178 | - if ( in_array( $name, $this->compat_fields ) ) { |
|
| 177 | + public function __get($name) { |
|
| 178 | + if (in_array($name, $this->compat_fields)) { |
|
| 179 | 179 | return $this->$name; |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | * @param mixed $value Property value. |
| 191 | 191 | * @return mixed Newly-set property. |
| 192 | 192 | */ |
| 193 | - public function __set( $name, $value ) { |
|
| 194 | - if ( in_array( $name, $this->compat_fields ) ) { |
|
| 193 | + public function __set($name, $value) { |
|
| 194 | + if (in_array($name, $this->compat_fields)) { |
|
| 195 | 195 | return $this->$name = $value; |
| 196 | 196 | } |
| 197 | 197 | } |
@@ -205,9 +205,9 @@ discard block |
||
| 205 | 205 | * @param string $name Property to check if set. |
| 206 | 206 | * @return bool Whether the property is set. |
| 207 | 207 | */ |
| 208 | - public function __isset( $name ) { |
|
| 209 | - if ( in_array( $name, $this->compat_fields ) ) { |
|
| 210 | - return isset( $this->$name ); |
|
| 208 | + public function __isset($name) { |
|
| 209 | + if (in_array($name, $this->compat_fields)) { |
|
| 210 | + return isset($this->$name); |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
@@ -219,9 +219,9 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @param string $name Property to unset. |
| 221 | 221 | */ |
| 222 | - public function __unset( $name ) { |
|
| 223 | - if ( in_array( $name, $this->compat_fields ) ) { |
|
| 224 | - unset( $this->$name ); |
|
| 222 | + public function __unset($name) { |
|
| 223 | + if (in_array($name, $this->compat_fields)) { |
|
| 224 | + unset($this->$name); |
|
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
@@ -235,9 +235,9 @@ discard block |
||
| 235 | 235 | * @param array $arguments Arguments to pass when calling. |
| 236 | 236 | * @return mixed|bool Return value of the callback, false otherwise. |
| 237 | 237 | */ |
| 238 | - public function __call( $name, $arguments ) { |
|
| 239 | - if ( in_array( $name, $this->compat_methods ) ) { |
|
| 240 | - return call_user_func_array( array( $this, $name ), $arguments ); |
|
| 238 | + public function __call($name, $arguments) { |
|
| 239 | + if (in_array($name, $this->compat_methods)) { |
|
| 240 | + return call_user_func_array(array($this, $name), $arguments); |
|
| 241 | 241 | } |
| 242 | 242 | return false; |
| 243 | 243 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * @abstract |
| 251 | 251 | */ |
| 252 | 252 | public function ajax_user_can() { |
| 253 | - die( 'function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.' ); |
|
| 253 | + die('function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.'); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * @abstract |
| 263 | 263 | */ |
| 264 | 264 | public function prepare_items() { |
| 265 | - die( 'function WP_List_Table::prepare_items() must be over-ridden in a sub-class.' ); |
|
| 265 | + die('function WP_List_Table::prepare_items() must be over-ridden in a sub-class.'); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -273,19 +273,19 @@ discard block |
||
| 273 | 273 | * |
| 274 | 274 | * @param array|string $args Array or string of arguments with information about the pagination. |
| 275 | 275 | */ |
| 276 | - protected function set_pagination_args( $args ) { |
|
| 277 | - $args = wp_parse_args( $args, array( |
|
| 276 | + protected function set_pagination_args($args) { |
|
| 277 | + $args = wp_parse_args($args, array( |
|
| 278 | 278 | 'total_items' => 0, |
| 279 | 279 | 'total_pages' => 0, |
| 280 | 280 | 'per_page' => 0, |
| 281 | - ) ); |
|
| 281 | + )); |
|
| 282 | 282 | |
| 283 | - if ( !$args['total_pages'] && $args['per_page'] > 0 ) |
|
| 284 | - $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); |
|
| 283 | + if ( ! $args['total_pages'] && $args['per_page'] > 0) |
|
| 284 | + $args['total_pages'] = ceil($args['total_items'] / $args['per_page']); |
|
| 285 | 285 | |
| 286 | 286 | // Redirect if page number is invalid and headers are not already sent. |
| 287 | - if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) { |
|
| 288 | - wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) ); |
|
| 287 | + if ( ! headers_sent() && ( ! defined('DOING_AJAX') || ! DOING_AJAX) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages']) { |
|
| 288 | + wp_redirect(add_query_arg('paged', $args['total_pages'])); |
|
| 289 | 289 | exit; |
| 290 | 290 | } |
| 291 | 291 | |
@@ -302,12 +302,12 @@ discard block |
||
| 302 | 302 | * 'total_pages', 'per_page', or 'infinite_scroll'. |
| 303 | 303 | * @return int Number of items that correspond to the given pagination argument. |
| 304 | 304 | */ |
| 305 | - public function get_pagination_arg( $key ) { |
|
| 306 | - if ( 'page' === $key ) { |
|
| 305 | + public function get_pagination_arg($key) { |
|
| 306 | + if ('page' === $key) { |
|
| 307 | 307 | return $this->get_pagenum(); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - if ( isset( $this->_pagination_args[$key] ) ) { |
|
| 310 | + if (isset($this->_pagination_args[$key])) { |
|
| 311 | 311 | return $this->_pagination_args[$key]; |
| 312 | 312 | } |
| 313 | 313 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * @return bool |
| 322 | 322 | */ |
| 323 | 323 | public function has_items() { |
| 324 | - return !empty( $this->items ); |
|
| 324 | + return ! empty($this->items); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * @access public |
| 332 | 332 | */ |
| 333 | 333 | public function no_items() { |
| 334 | - _e( 'No items found.' ); |
|
| 334 | + _e('No items found.'); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -343,25 +343,25 @@ discard block |
||
| 343 | 343 | * @param string $text The 'submit' button label. |
| 344 | 344 | * @param string $input_id ID attribute value for the search input field. |
| 345 | 345 | */ |
| 346 | - public function search_box( $text, $input_id ) { |
|
| 347 | - if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) |
|
| 346 | + public function search_box($text, $input_id) { |
|
| 347 | + if (empty($_REQUEST['s']) && ! $this->has_items()) |
|
| 348 | 348 | return; |
| 349 | 349 | |
| 350 | - $input_id = $input_id . '-search-input'; |
|
| 350 | + $input_id = $input_id.'-search-input'; |
|
| 351 | 351 | |
| 352 | - if ( ! empty( $_REQUEST['orderby'] ) ) |
|
| 353 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
| 354 | - if ( ! empty( $_REQUEST['order'] ) ) |
|
| 355 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
| 356 | - if ( ! empty( $_REQUEST['post_mime_type'] ) ) |
|
| 357 | - echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; |
|
| 358 | - if ( ! empty( $_REQUEST['detached'] ) ) |
|
| 359 | - echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; |
|
| 352 | + if ( ! empty($_REQUEST['orderby'])) |
|
| 353 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
| 354 | + if ( ! empty($_REQUEST['order'])) |
|
| 355 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
| 356 | + if ( ! empty($_REQUEST['post_mime_type'])) |
|
| 357 | + echo '<input type="hidden" name="post_mime_type" value="'.esc_attr($_REQUEST['post_mime_type']).'" />'; |
|
| 358 | + if ( ! empty($_REQUEST['detached'])) |
|
| 359 | + echo '<input type="hidden" name="detached" value="'.esc_attr($_REQUEST['detached']).'" />'; |
|
| 360 | 360 | ?> |
| 361 | 361 | <p class="search-box"> |
| 362 | - <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label> |
|
| 363 | - <input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
|
| 364 | - <?php submit_button( $text, 'button', '', false, array( 'id' => 'search-submit' ) ); ?> |
|
| 362 | + <label class="screen-reader-text" for="<?php echo esc_attr($input_id); ?>"><?php echo $text; ?>:</label> |
|
| 363 | + <input type="search" id="<?php echo esc_attr($input_id); ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
|
| 364 | + <?php submit_button($text, 'button', '', false, array('id' => 'search-submit')); ?> |
|
| 365 | 365 | </p> |
| 366 | 366 | <?php |
| 367 | 367 | } |
@@ -397,18 +397,18 @@ discard block |
||
| 397 | 397 | * |
| 398 | 398 | * @param array $views An array of available list table views. |
| 399 | 399 | */ |
| 400 | - $views = apply_filters( "views_{$this->screen->id}", $views ); |
|
| 400 | + $views = apply_filters("views_{$this->screen->id}", $views); |
|
| 401 | 401 | |
| 402 | - if ( empty( $views ) ) |
|
| 402 | + if (empty($views)) |
|
| 403 | 403 | return; |
| 404 | 404 | |
| 405 | - $this->screen->render_screen_reader_content( 'heading_views' ); |
|
| 405 | + $this->screen->render_screen_reader_content('heading_views'); |
|
| 406 | 406 | |
| 407 | 407 | echo "<ul class='subsubsub'>\n"; |
| 408 | - foreach ( $views as $class => $view ) { |
|
| 409 | - $views[ $class ] = "\t<li class='$class'>$view"; |
|
| 408 | + foreach ($views as $class => $view) { |
|
| 409 | + $views[$class] = "\t<li class='$class'>$view"; |
|
| 410 | 410 | } |
| 411 | - echo implode( " |</li>\n", $views ) . "</li>\n"; |
|
| 411 | + echo implode(" |</li>\n", $views)."</li>\n"; |
|
| 412 | 412 | echo "</ul>"; |
| 413 | 413 | } |
| 414 | 414 | |
@@ -434,8 +434,8 @@ discard block |
||
| 434 | 434 | * @param string $which The location of the bulk actions: 'top' or 'bottom'. |
| 435 | 435 | * This is designated as optional for backward compatibility. |
| 436 | 436 | */ |
| 437 | - protected function bulk_actions( $which = '' ) { |
|
| 438 | - if ( is_null( $this->_actions ) ) { |
|
| 437 | + protected function bulk_actions($which = '') { |
|
| 438 | + if (is_null($this->_actions)) { |
|
| 439 | 439 | $no_new_actions = $this->_actions = $this->get_bulk_actions(); |
| 440 | 440 | /** |
| 441 | 441 | * Filters the list table Bulk Actions drop-down. |
@@ -449,29 +449,29 @@ discard block |
||
| 449 | 449 | * |
| 450 | 450 | * @param array $actions An array of the available bulk actions. |
| 451 | 451 | */ |
| 452 | - $this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); |
|
| 453 | - $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions ); |
|
| 452 | + $this->_actions = apply_filters("bulk_actions-{$this->screen->id}", $this->_actions); |
|
| 453 | + $this->_actions = array_intersect_assoc($this->_actions, $no_new_actions); |
|
| 454 | 454 | $two = ''; |
| 455 | 455 | } else { |
| 456 | 456 | $two = '2'; |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - if ( empty( $this->_actions ) ) |
|
| 459 | + if (empty($this->_actions)) |
|
| 460 | 460 | return; |
| 461 | 461 | |
| 462 | - echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>'; |
|
| 463 | - echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n"; |
|
| 464 | - echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>\n"; |
|
| 462 | + echo '<label for="bulk-action-selector-'.esc_attr($which).'" class="screen-reader-text">'.__('Select bulk action').'</label>'; |
|
| 463 | + echo '<select name="action'.$two.'" id="bulk-action-selector-'.esc_attr($which)."\">\n"; |
|
| 464 | + echo '<option value="-1">'.__('Bulk Actions')."</option>\n"; |
|
| 465 | 465 | |
| 466 | - foreach ( $this->_actions as $name => $title ) { |
|
| 466 | + foreach ($this->_actions as $name => $title) { |
|
| 467 | 467 | $class = 'edit' === $name ? ' class="hide-if-no-js"' : ''; |
| 468 | 468 | |
| 469 | - echo "\t" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>\n"; |
|
| 469 | + echo "\t".'<option value="'.$name.'"'.$class.'>'.$title."</option>\n"; |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | echo "</select>\n"; |
| 473 | 473 | |
| 474 | - submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
|
| 474 | + submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two")); |
|
| 475 | 475 | echo "\n"; |
| 476 | 476 | } |
| 477 | 477 | |
@@ -484,13 +484,13 @@ discard block |
||
| 484 | 484 | * @return string|false The action name or False if no action was selected |
| 485 | 485 | */ |
| 486 | 486 | public function current_action() { |
| 487 | - if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) |
|
| 487 | + if (isset($_REQUEST['filter_action']) && ! empty($_REQUEST['filter_action'])) |
|
| 488 | 488 | return false; |
| 489 | 489 | |
| 490 | - if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) |
|
| 490 | + if (isset($_REQUEST['action']) && -1 != $_REQUEST['action']) |
|
| 491 | 491 | return $_REQUEST['action']; |
| 492 | 492 | |
| 493 | - if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) |
|
| 493 | + if (isset($_REQUEST['action2']) && -1 != $_REQUEST['action2']) |
|
| 494 | 494 | return $_REQUEST['action2']; |
| 495 | 495 | |
| 496 | 496 | return false; |
@@ -506,22 +506,22 @@ discard block |
||
| 506 | 506 | * @param bool $always_visible Whether the actions should be always visible |
| 507 | 507 | * @return string |
| 508 | 508 | */ |
| 509 | - protected function row_actions( $actions, $always_visible = false ) { |
|
| 510 | - $action_count = count( $actions ); |
|
| 509 | + protected function row_actions($actions, $always_visible = false) { |
|
| 510 | + $action_count = count($actions); |
|
| 511 | 511 | $i = 0; |
| 512 | 512 | |
| 513 | - if ( !$action_count ) |
|
| 513 | + if ( ! $action_count) |
|
| 514 | 514 | return ''; |
| 515 | 515 | |
| 516 | - $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
|
| 517 | - foreach ( $actions as $action => $link ) { |
|
| 516 | + $out = '<div class="'.($always_visible ? 'row-actions visible' : 'row-actions').'">'; |
|
| 517 | + foreach ($actions as $action => $link) { |
|
| 518 | 518 | ++$i; |
| 519 | - ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
|
| 519 | + ($i == $action_count) ? $sep = '' : $sep = ' | '; |
|
| 520 | 520 | $out .= "<span class='$action'>$link$sep</span>"; |
| 521 | 521 | } |
| 522 | 522 | $out .= '</div>'; |
| 523 | 523 | |
| 524 | - $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>'; |
|
| 524 | + $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">'.__('Show more details').'</span></button>'; |
|
| 525 | 525 | |
| 526 | 526 | return $out; |
| 527 | 527 | } |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | * |
| 538 | 538 | * @param string $post_type |
| 539 | 539 | */ |
| 540 | - protected function months_dropdown( $post_type ) { |
|
| 540 | + protected function months_dropdown($post_type) { |
|
| 541 | 541 | global $wpdb, $wp_locale; |
| 542 | 542 | |
| 543 | 543 | /** |
@@ -548,24 +548,24 @@ discard block |
||
| 548 | 548 | * @param bool $disable Whether to disable the drop-down. Default false. |
| 549 | 549 | * @param string $post_type The post type. |
| 550 | 550 | */ |
| 551 | - if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) { |
|
| 551 | + if (apply_filters('disable_months_dropdown', false, $post_type)) { |
|
| 552 | 552 | return; |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | $extra_checks = "AND post_status != 'auto-draft'"; |
| 556 | - if ( ! isset( $_GET['post_status'] ) || 'trash' !== $_GET['post_status'] ) { |
|
| 556 | + if ( ! isset($_GET['post_status']) || 'trash' !== $_GET['post_status']) { |
|
| 557 | 557 | $extra_checks .= " AND post_status != 'trash'"; |
| 558 | - } elseif ( isset( $_GET['post_status'] ) ) { |
|
| 559 | - $extra_checks = $wpdb->prepare( ' AND post_status = %s', $_GET['post_status'] ); |
|
| 558 | + } elseif (isset($_GET['post_status'])) { |
|
| 559 | + $extra_checks = $wpdb->prepare(' AND post_status = %s', $_GET['post_status']); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - $months = $wpdb->get_results( $wpdb->prepare( " |
|
| 562 | + $months = $wpdb->get_results($wpdb->prepare(" |
|
| 563 | 563 | SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month |
| 564 | 564 | FROM $wpdb->posts |
| 565 | 565 | WHERE post_type = %s |
| 566 | 566 | $extra_checks |
| 567 | 567 | ORDER BY post_date DESC |
| 568 | - ", $post_type ) ); |
|
| 568 | + ", $post_type)); |
|
| 569 | 569 | |
| 570 | 570 | /** |
| 571 | 571 | * Filters the 'Months' drop-down results. |
@@ -575,31 +575,31 @@ discard block |
||
| 575 | 575 | * @param object $months The months drop-down query results. |
| 576 | 576 | * @param string $post_type The post type. |
| 577 | 577 | */ |
| 578 | - $months = apply_filters( 'months_dropdown_results', $months, $post_type ); |
|
| 578 | + $months = apply_filters('months_dropdown_results', $months, $post_type); |
|
| 579 | 579 | |
| 580 | - $month_count = count( $months ); |
|
| 580 | + $month_count = count($months); |
|
| 581 | 581 | |
| 582 | - if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) |
|
| 582 | + if ( ! $month_count || (1 == $month_count && 0 == $months[0]->month)) |
|
| 583 | 583 | return; |
| 584 | 584 | |
| 585 | - $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; |
|
| 585 | + $m = isset($_GET['m']) ? (int) $_GET['m'] : 0; |
|
| 586 | 586 | ?> |
| 587 | - <label for="filter-by-date" class="screen-reader-text"><?php _e( 'Filter by date' ); ?></label> |
|
| 587 | + <label for="filter-by-date" class="screen-reader-text"><?php _e('Filter by date'); ?></label> |
|
| 588 | 588 | <select name="m" id="filter-by-date"> |
| 589 | - <option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option> |
|
| 589 | + <option<?php selected($m, 0); ?> value="0"><?php _e('All dates'); ?></option> |
|
| 590 | 590 | <?php |
| 591 | - foreach ( $months as $arc_row ) { |
|
| 592 | - if ( 0 == $arc_row->year ) |
|
| 591 | + foreach ($months as $arc_row) { |
|
| 592 | + if (0 == $arc_row->year) |
|
| 593 | 593 | continue; |
| 594 | 594 | |
| 595 | - $month = zeroise( $arc_row->month, 2 ); |
|
| 595 | + $month = zeroise($arc_row->month, 2); |
|
| 596 | 596 | $year = $arc_row->year; |
| 597 | 597 | |
| 598 | - printf( "<option %s value='%s'>%s</option>\n", |
|
| 599 | - selected( $m, $year . $month, false ), |
|
| 600 | - esc_attr( $arc_row->year . $month ), |
|
| 598 | + printf("<option %s value='%s'>%s</option>\n", |
|
| 599 | + selected($m, $year.$month, false), |
|
| 600 | + esc_attr($arc_row->year.$month), |
|
| 601 | 601 | /* translators: 1: month name, 2: 4-digit year */ |
| 602 | - sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) |
|
| 602 | + sprintf(__('%1$s %2$d'), $wp_locale->get_month($month), $year) |
|
| 603 | 603 | ); |
| 604 | 604 | } |
| 605 | 605 | ?> |
@@ -615,19 +615,19 @@ discard block |
||
| 615 | 615 | * |
| 616 | 616 | * @param string $current_mode |
| 617 | 617 | */ |
| 618 | - protected function view_switcher( $current_mode ) { |
|
| 618 | + protected function view_switcher($current_mode) { |
|
| 619 | 619 | ?> |
| 620 | - <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" /> |
|
| 620 | + <input type="hidden" name="mode" value="<?php echo esc_attr($current_mode); ?>" /> |
|
| 621 | 621 | <div class="view-switch"> |
| 622 | 622 | <?php |
| 623 | - foreach ( $this->modes as $mode => $title ) { |
|
| 624 | - $classes = array( 'view-' . $mode ); |
|
| 625 | - if ( $current_mode === $mode ) |
|
| 623 | + foreach ($this->modes as $mode => $title) { |
|
| 624 | + $classes = array('view-'.$mode); |
|
| 625 | + if ($current_mode === $mode) |
|
| 626 | 626 | $classes[] = 'current'; |
| 627 | 627 | printf( |
| 628 | 628 | "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n", |
| 629 | - esc_url( add_query_arg( 'mode', $mode ) ), |
|
| 630 | - implode( ' ', $classes ), |
|
| 629 | + esc_url(add_query_arg('mode', $mode)), |
|
| 630 | + implode(' ', $classes), |
|
| 631 | 631 | $title |
| 632 | 632 | ); |
| 633 | 633 | } |
@@ -645,45 +645,45 @@ discard block |
||
| 645 | 645 | * @param int $post_id The post ID. |
| 646 | 646 | * @param int $pending_comments Number of pending comments. |
| 647 | 647 | */ |
| 648 | - protected function comments_bubble( $post_id, $pending_comments ) { |
|
| 648 | + protected function comments_bubble($post_id, $pending_comments) { |
|
| 649 | 649 | $approved_comments = get_comments_number(); |
| 650 | 650 | |
| 651 | - $approved_comments_number = number_format_i18n( $approved_comments ); |
|
| 652 | - $pending_comments_number = number_format_i18n( $pending_comments ); |
|
| 651 | + $approved_comments_number = number_format_i18n($approved_comments); |
|
| 652 | + $pending_comments_number = number_format_i18n($pending_comments); |
|
| 653 | 653 | |
| 654 | - $approved_only_phrase = sprintf( _n( '%s comment', '%s comments', $approved_comments ), $approved_comments_number ); |
|
| 655 | - $approved_phrase = sprintf( _n( '%s approved comment', '%s approved comments', $approved_comments ), $approved_comments_number ); |
|
| 656 | - $pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number ); |
|
| 654 | + $approved_only_phrase = sprintf(_n('%s comment', '%s comments', $approved_comments), $approved_comments_number); |
|
| 655 | + $approved_phrase = sprintf(_n('%s approved comment', '%s approved comments', $approved_comments), $approved_comments_number); |
|
| 656 | + $pending_phrase = sprintf(_n('%s pending comment', '%s pending comments', $pending_comments), $pending_comments_number); |
|
| 657 | 657 | |
| 658 | 658 | // No comments at all. |
| 659 | - if ( ! $approved_comments && ! $pending_comments ) { |
|
| 660 | - printf( '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>', |
|
| 661 | - __( 'No comments' ) |
|
| 659 | + if ( ! $approved_comments && ! $pending_comments) { |
|
| 660 | + printf('<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>', |
|
| 661 | + __('No comments') |
|
| 662 | 662 | ); |
| 663 | 663 | // Approved comments have different display depending on some conditions. |
| 664 | - } elseif ( $approved_comments ) { |
|
| 665 | - printf( '<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
|
| 666 | - esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'approved' ), admin_url( 'edit-comments.php' ) ) ), |
|
| 664 | + } elseif ($approved_comments) { |
|
| 665 | + printf('<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
|
| 666 | + esc_url(add_query_arg(array('p' => $post_id, 'comment_status' => 'approved'), admin_url('edit-comments.php'))), |
|
| 667 | 667 | $approved_comments_number, |
| 668 | 668 | $pending_comments ? $approved_phrase : $approved_only_phrase |
| 669 | 669 | ); |
| 670 | 670 | } else { |
| 671 | - printf( '<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
|
| 671 | + printf('<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
|
| 672 | 672 | $approved_comments_number, |
| 673 | - $pending_comments ? __( 'No approved comments' ) : __( 'No comments' ) |
|
| 673 | + $pending_comments ? __('No approved comments') : __('No comments') |
|
| 674 | 674 | ); |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | - if ( $pending_comments ) { |
|
| 678 | - printf( '<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
|
| 679 | - esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'moderated' ), admin_url( 'edit-comments.php' ) ) ), |
|
| 677 | + if ($pending_comments) { |
|
| 678 | + printf('<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
|
| 679 | + esc_url(add_query_arg(array('p' => $post_id, 'comment_status' => 'moderated'), admin_url('edit-comments.php'))), |
|
| 680 | 680 | $pending_comments_number, |
| 681 | 681 | $pending_phrase |
| 682 | 682 | ); |
| 683 | 683 | } else { |
| 684 | - printf( '<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
|
| 684 | + printf('<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
|
| 685 | 685 | $pending_comments_number, |
| 686 | - $approved_comments ? __( 'No pending comments' ) : __( 'No comments' ) |
|
| 686 | + $approved_comments ? __('No pending comments') : __('No comments') |
|
| 687 | 687 | ); |
| 688 | 688 | } |
| 689 | 689 | } |
@@ -697,12 +697,12 @@ discard block |
||
| 697 | 697 | * @return int |
| 698 | 698 | */ |
| 699 | 699 | public function get_pagenum() { |
| 700 | - $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0; |
|
| 700 | + $pagenum = isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 0; |
|
| 701 | 701 | |
| 702 | - if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) |
|
| 702 | + if (isset($this->_pagination_args['total_pages']) && $pagenum > $this->_pagination_args['total_pages']) |
|
| 703 | 703 | $pagenum = $this->_pagination_args['total_pages']; |
| 704 | 704 | |
| 705 | - return max( 1, $pagenum ); |
|
| 705 | + return max(1, $pagenum); |
|
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | /** |
@@ -715,9 +715,9 @@ discard block |
||
| 715 | 715 | * @param int $default |
| 716 | 716 | * @return int |
| 717 | 717 | */ |
| 718 | - protected function get_items_per_page( $option, $default = 20 ) { |
|
| 719 | - $per_page = (int) get_user_option( $option ); |
|
| 720 | - if ( empty( $per_page ) || $per_page < 1 ) |
|
| 718 | + protected function get_items_per_page($option, $default = 20) { |
|
| 719 | + $per_page = (int) get_user_option($option); |
|
| 720 | + if (empty($per_page) || $per_page < 1) |
|
| 721 | 721 | $per_page = $default; |
| 722 | 722 | |
| 723 | 723 | /** |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | * |
| 734 | 734 | * @param int $per_page Number of items to be displayed. Default 20. |
| 735 | 735 | */ |
| 736 | - return (int) apply_filters( $option, $per_page ); |
|
| 736 | + return (int) apply_filters($option, $per_page); |
|
| 737 | 737 | } |
| 738 | 738 | |
| 739 | 739 | /** |
@@ -744,30 +744,30 @@ discard block |
||
| 744 | 744 | * |
| 745 | 745 | * @param string $which |
| 746 | 746 | */ |
| 747 | - protected function pagination( $which ) { |
|
| 748 | - if ( empty( $this->_pagination_args ) ) { |
|
| 747 | + protected function pagination($which) { |
|
| 748 | + if (empty($this->_pagination_args)) { |
|
| 749 | 749 | return; |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | $total_items = $this->_pagination_args['total_items']; |
| 753 | 753 | $total_pages = $this->_pagination_args['total_pages']; |
| 754 | 754 | $infinite_scroll = false; |
| 755 | - if ( isset( $this->_pagination_args['infinite_scroll'] ) ) { |
|
| 755 | + if (isset($this->_pagination_args['infinite_scroll'])) { |
|
| 756 | 756 | $infinite_scroll = $this->_pagination_args['infinite_scroll']; |
| 757 | 757 | } |
| 758 | 758 | |
| 759 | - if ( 'top' === $which && $total_pages > 1 ) { |
|
| 760 | - $this->screen->render_screen_reader_content( 'heading_pagination' ); |
|
| 759 | + if ('top' === $which && $total_pages > 1) { |
|
| 760 | + $this->screen->render_screen_reader_content('heading_pagination'); |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | - $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>'; |
|
| 763 | + $output = '<span class="displaying-num">'.sprintf(_n('%s item', '%s items', $total_items), number_format_i18n($total_items)).'</span>'; |
|
| 764 | 764 | |
| 765 | 765 | $current = $this->get_pagenum(); |
| 766 | 766 | $removable_query_args = wp_removable_query_args(); |
| 767 | 767 | |
| 768 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
| 768 | + $current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
| 769 | 769 | |
| 770 | - $current_url = remove_query_arg( $removable_query_args, $current_url ); |
|
| 770 | + $current_url = remove_query_arg($removable_query_args, $current_url); |
|
| 771 | 771 | |
| 772 | 772 | $page_links = array(); |
| 773 | 773 | |
@@ -776,81 +776,81 @@ discard block |
||
| 776 | 776 | |
| 777 | 777 | $disable_first = $disable_last = $disable_prev = $disable_next = false; |
| 778 | 778 | |
| 779 | - if ( $current == 1 ) { |
|
| 779 | + if ($current == 1) { |
|
| 780 | 780 | $disable_first = true; |
| 781 | 781 | $disable_prev = true; |
| 782 | 782 | } |
| 783 | - if ( $current == 2 ) { |
|
| 783 | + if ($current == 2) { |
|
| 784 | 784 | $disable_first = true; |
| 785 | 785 | } |
| 786 | - if ( $current == $total_pages ) { |
|
| 786 | + if ($current == $total_pages) { |
|
| 787 | 787 | $disable_last = true; |
| 788 | 788 | $disable_next = true; |
| 789 | 789 | } |
| 790 | - if ( $current == $total_pages - 1 ) { |
|
| 790 | + if ($current == $total_pages - 1) { |
|
| 791 | 791 | $disable_last = true; |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | - if ( $disable_first ) { |
|
| 794 | + if ($disable_first) { |
|
| 795 | 795 | $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">«</span>'; |
| 796 | 796 | } else { |
| 797 | - $page_links[] = sprintf( "<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 798 | - esc_url( remove_query_arg( 'paged', $current_url ) ), |
|
| 799 | - __( 'First page' ), |
|
| 797 | + $page_links[] = sprintf("<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 798 | + esc_url(remove_query_arg('paged', $current_url)), |
|
| 799 | + __('First page'), |
|
| 800 | 800 | '«' |
| 801 | 801 | ); |
| 802 | 802 | } |
| 803 | 803 | |
| 804 | - if ( $disable_prev ) { |
|
| 804 | + if ($disable_prev) { |
|
| 805 | 805 | $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">‹</span>'; |
| 806 | 806 | } else { |
| 807 | - $page_links[] = sprintf( "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 808 | - esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ), |
|
| 809 | - __( 'Previous page' ), |
|
| 807 | + $page_links[] = sprintf("<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 808 | + esc_url(add_query_arg('paged', max(1, $current - 1), $current_url)), |
|
| 809 | + __('Previous page'), |
|
| 810 | 810 | '‹' |
| 811 | 811 | ); |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | - if ( 'bottom' === $which ) { |
|
| 814 | + if ('bottom' === $which) { |
|
| 815 | 815 | $html_current_page = $current; |
| 816 | - $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">'; |
|
| 816 | + $total_pages_before = '<span class="screen-reader-text">'.__('Current Page').'</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">'; |
|
| 817 | 817 | } else { |
| 818 | - $html_current_page = sprintf( "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>", |
|
| 819 | - '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>', |
|
| 818 | + $html_current_page = sprintf("%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>", |
|
| 819 | + '<label for="current-page-selector" class="screen-reader-text">'.__('Current Page').'</label>', |
|
| 820 | 820 | $current, |
| 821 | - strlen( $total_pages ) |
|
| 821 | + strlen($total_pages) |
|
| 822 | 822 | ); |
| 823 | 823 | } |
| 824 | - $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) ); |
|
| 825 | - $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after; |
|
| 824 | + $html_total_pages = sprintf("<span class='total-pages'>%s</span>", number_format_i18n($total_pages)); |
|
| 825 | + $page_links[] = $total_pages_before.sprintf(_x('%1$s of %2$s', 'paging'), $html_current_page, $html_total_pages).$total_pages_after; |
|
| 826 | 826 | |
| 827 | - if ( $disable_next ) { |
|
| 827 | + if ($disable_next) { |
|
| 828 | 828 | $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">›</span>'; |
| 829 | 829 | } else { |
| 830 | - $page_links[] = sprintf( "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 831 | - esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ), |
|
| 832 | - __( 'Next page' ), |
|
| 830 | + $page_links[] = sprintf("<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 831 | + esc_url(add_query_arg('paged', min($total_pages, $current + 1), $current_url)), |
|
| 832 | + __('Next page'), |
|
| 833 | 833 | '›' |
| 834 | 834 | ); |
| 835 | 835 | } |
| 836 | 836 | |
| 837 | - if ( $disable_last ) { |
|
| 837 | + if ($disable_last) { |
|
| 838 | 838 | $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">»</span>'; |
| 839 | 839 | } else { |
| 840 | - $page_links[] = sprintf( "<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 841 | - esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ), |
|
| 842 | - __( 'Last page' ), |
|
| 840 | + $page_links[] = sprintf("<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
| 841 | + esc_url(add_query_arg('paged', $total_pages, $current_url)), |
|
| 842 | + __('Last page'), |
|
| 843 | 843 | '»' |
| 844 | 844 | ); |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | $pagination_links_class = 'pagination-links'; |
| 848 | - if ( ! empty( $infinite_scroll ) ) { |
|
| 848 | + if ( ! empty($infinite_scroll)) { |
|
| 849 | 849 | $pagination_links_class = ' hide-if-js'; |
| 850 | 850 | } |
| 851 | - $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>'; |
|
| 851 | + $output .= "\n<span class='$pagination_links_class'>".join("\n", $page_links).'</span>'; |
|
| 852 | 852 | |
| 853 | - if ( $total_pages ) { |
|
| 853 | + if ($total_pages) { |
|
| 854 | 854 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
| 855 | 855 | } else { |
| 856 | 856 | $page_class = ' no-pages'; |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | * @return array |
| 872 | 872 | */ |
| 873 | 873 | public function get_columns() { |
| 874 | - die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' ); |
|
| 874 | + die('function WP_List_Table::get_columns() must be over-ridden in a sub-class.'); |
|
| 875 | 875 | } |
| 876 | 876 | |
| 877 | 877 | /** |
@@ -903,14 +903,14 @@ discard block |
||
| 903 | 903 | $columns = $this->get_columns(); |
| 904 | 904 | $column = ''; |
| 905 | 905 | |
| 906 | - if ( empty( $columns ) ) { |
|
| 906 | + if (empty($columns)) { |
|
| 907 | 907 | return $column; |
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | // We need a primary defined so responsive views show something, |
| 911 | 911 | // so let's fall back to the first non-checkbox column. |
| 912 | - foreach ( $columns as $col => $column_name ) { |
|
| 913 | - if ( 'cb' === $col ) { |
|
| 912 | + foreach ($columns as $col => $column_name) { |
|
| 913 | + if ('cb' === $col) { |
|
| 914 | 914 | continue; |
| 915 | 915 | } |
| 916 | 916 | |
@@ -942,12 +942,12 @@ discard block |
||
| 942 | 942 | * @return string The name of the primary column. |
| 943 | 943 | */ |
| 944 | 944 | protected function get_primary_column_name() { |
| 945 | - $columns = get_column_headers( $this->screen ); |
|
| 945 | + $columns = get_column_headers($this->screen); |
|
| 946 | 946 | $default = $this->get_default_primary_column_name(); |
| 947 | 947 | |
| 948 | 948 | // If the primary column doesn't exist fall back to the |
| 949 | 949 | // first non-checkbox column. |
| 950 | - if ( ! isset( $columns[ $default ] ) ) { |
|
| 950 | + if ( ! isset($columns[$default])) { |
|
| 951 | 951 | $default = WP_List_Table::get_default_primary_column_name(); |
| 952 | 952 | } |
| 953 | 953 | |
@@ -959,9 +959,9 @@ discard block |
||
| 959 | 959 | * @param string $default Column name default for the specific list table, e.g. 'name'. |
| 960 | 960 | * @param string $context Screen ID for specific list table, e.g. 'plugins'. |
| 961 | 961 | */ |
| 962 | - $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); |
|
| 962 | + $column = apply_filters('list_table_primary_column', $default, $this->screen->id); |
|
| 963 | 963 | |
| 964 | - if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { |
|
| 964 | + if (empty($column) || ! isset($columns[$column])) { |
|
| 965 | 965 | $column = $default; |
| 966 | 966 | } |
| 967 | 967 | |
@@ -978,19 +978,19 @@ discard block |
||
| 978 | 978 | */ |
| 979 | 979 | protected function get_column_info() { |
| 980 | 980 | // $_column_headers is already set / cached |
| 981 | - if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) { |
|
| 981 | + if (isset($this->_column_headers) && is_array($this->_column_headers)) { |
|
| 982 | 982 | // Back-compat for list tables that have been manually setting $_column_headers for horse reasons. |
| 983 | 983 | // In 4.3, we added a fourth argument for primary column. |
| 984 | - $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); |
|
| 985 | - foreach ( $this->_column_headers as $key => $value ) { |
|
| 986 | - $column_headers[ $key ] = $value; |
|
| 984 | + $column_headers = array(array(), array(), array(), $this->get_primary_column_name()); |
|
| 985 | + foreach ($this->_column_headers as $key => $value) { |
|
| 986 | + $column_headers[$key] = $value; |
|
| 987 | 987 | } |
| 988 | 988 | |
| 989 | 989 | return $column_headers; |
| 990 | 990 | } |
| 991 | 991 | |
| 992 | - $columns = get_column_headers( $this->screen ); |
|
| 993 | - $hidden = get_hidden_columns( $this->screen ); |
|
| 992 | + $columns = get_column_headers($this->screen); |
|
| 993 | + $hidden = get_hidden_columns($this->screen); |
|
| 994 | 994 | |
| 995 | 995 | $sortable_columns = $this->get_sortable_columns(); |
| 996 | 996 | /** |
@@ -1003,22 +1003,22 @@ discard block |
||
| 1003 | 1003 | * |
| 1004 | 1004 | * @param array $sortable_columns An array of sortable columns. |
| 1005 | 1005 | */ |
| 1006 | - $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns ); |
|
| 1006 | + $_sortable = apply_filters("manage_{$this->screen->id}_sortable_columns", $sortable_columns); |
|
| 1007 | 1007 | |
| 1008 | 1008 | $sortable = array(); |
| 1009 | - foreach ( $_sortable as $id => $data ) { |
|
| 1010 | - if ( empty( $data ) ) |
|
| 1009 | + foreach ($_sortable as $id => $data) { |
|
| 1010 | + if (empty($data)) |
|
| 1011 | 1011 | continue; |
| 1012 | 1012 | |
| 1013 | 1013 | $data = (array) $data; |
| 1014 | - if ( !isset( $data[1] ) ) |
|
| 1014 | + if ( ! isset($data[1])) |
|
| 1015 | 1015 | $data[1] = false; |
| 1016 | 1016 | |
| 1017 | 1017 | $sortable[$id] = $data; |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | $primary = $this->get_primary_column_name(); |
| 1021 | - $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); |
|
| 1021 | + $this->_column_headers = array($columns, $hidden, $sortable, $primary); |
|
| 1022 | 1022 | |
| 1023 | 1023 | return $this->_column_headers; |
| 1024 | 1024 | } |
@@ -1032,9 +1032,9 @@ discard block |
||
| 1032 | 1032 | * @return int |
| 1033 | 1033 | */ |
| 1034 | 1034 | public function get_column_count() { |
| 1035 | - list ( $columns, $hidden ) = $this->get_column_info(); |
|
| 1036 | - $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) ); |
|
| 1037 | - return count( $columns ) - count( $hidden ); |
|
| 1035 | + list ($columns, $hidden) = $this->get_column_info(); |
|
| 1036 | + $hidden = array_intersect(array_keys($columns), array_filter($hidden)); |
|
| 1037 | + return count($columns) - count($hidden); |
|
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | 1040 | /** |
@@ -1047,51 +1047,51 @@ discard block |
||
| 1047 | 1047 | * |
| 1048 | 1048 | * @param bool $with_id Whether to set the id attribute or not |
| 1049 | 1049 | */ |
| 1050 | - public function print_column_headers( $with_id = true ) { |
|
| 1051 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
| 1050 | + public function print_column_headers($with_id = true) { |
|
| 1051 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
| 1052 | 1052 | |
| 1053 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
| 1054 | - $current_url = remove_query_arg( 'paged', $current_url ); |
|
| 1053 | + $current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
| 1054 | + $current_url = remove_query_arg('paged', $current_url); |
|
| 1055 | 1055 | |
| 1056 | - if ( isset( $_GET['orderby'] ) ) { |
|
| 1056 | + if (isset($_GET['orderby'])) { |
|
| 1057 | 1057 | $current_orderby = $_GET['orderby']; |
| 1058 | 1058 | } else { |
| 1059 | 1059 | $current_orderby = ''; |
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | - if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) { |
|
| 1062 | + if (isset($_GET['order']) && 'desc' === $_GET['order']) { |
|
| 1063 | 1063 | $current_order = 'desc'; |
| 1064 | 1064 | } else { |
| 1065 | 1065 | $current_order = 'asc'; |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | - if ( ! empty( $columns['cb'] ) ) { |
|
| 1068 | + if ( ! empty($columns['cb'])) { |
|
| 1069 | 1069 | static $cb_counter = 1; |
| 1070 | - $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>' |
|
| 1071 | - . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />'; |
|
| 1070 | + $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-'.$cb_counter.'">'.__('Select All').'</label>' |
|
| 1071 | + . '<input id="cb-select-all-'.$cb_counter.'" type="checkbox" />'; |
|
| 1072 | 1072 | $cb_counter++; |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | - foreach ( $columns as $column_key => $column_display_name ) { |
|
| 1076 | - $class = array( 'manage-column', "column-$column_key" ); |
|
| 1075 | + foreach ($columns as $column_key => $column_display_name) { |
|
| 1076 | + $class = array('manage-column', "column-$column_key"); |
|
| 1077 | 1077 | |
| 1078 | - if ( in_array( $column_key, $hidden ) ) { |
|
| 1078 | + if (in_array($column_key, $hidden)) { |
|
| 1079 | 1079 | $class[] = 'hidden'; |
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | - if ( 'cb' === $column_key ) |
|
| 1082 | + if ('cb' === $column_key) |
|
| 1083 | 1083 | $class[] = 'check-column'; |
| 1084 | - elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) |
|
| 1084 | + elseif (in_array($column_key, array('posts', 'comments', 'links'))) |
|
| 1085 | 1085 | $class[] = 'num'; |
| 1086 | 1086 | |
| 1087 | - if ( $column_key === $primary ) { |
|
| 1087 | + if ($column_key === $primary) { |
|
| 1088 | 1088 | $class[] = 'column-primary'; |
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | - if ( isset( $sortable[$column_key] ) ) { |
|
| 1092 | - list( $orderby, $desc_first ) = $sortable[$column_key]; |
|
| 1091 | + if (isset($sortable[$column_key])) { |
|
| 1092 | + list($orderby, $desc_first) = $sortable[$column_key]; |
|
| 1093 | 1093 | |
| 1094 | - if ( $current_orderby === $orderby ) { |
|
| 1094 | + if ($current_orderby === $orderby) { |
|
| 1095 | 1095 | $order = 'asc' === $current_order ? 'desc' : 'asc'; |
| 1096 | 1096 | $class[] = 'sorted'; |
| 1097 | 1097 | $class[] = $current_order; |
@@ -1101,15 +1101,15 @@ discard block |
||
| 1101 | 1101 | $class[] = $desc_first ? 'asc' : 'desc'; |
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | - $column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>'; |
|
| 1104 | + $column_display_name = '<a href="'.esc_url(add_query_arg(compact('orderby', 'order'), $current_url)).'"><span>'.$column_display_name.'</span><span class="sorting-indicator"></span></a>'; |
|
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | - $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; |
|
| 1108 | - $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; |
|
| 1107 | + $tag = ('cb' === $column_key) ? 'td' : 'th'; |
|
| 1108 | + $scope = ('th' === $tag) ? 'scope="col"' : ''; |
|
| 1109 | 1109 | $id = $with_id ? "id='$column_key'" : ''; |
| 1110 | 1110 | |
| 1111 | - if ( !empty( $class ) ) |
|
| 1112 | - $class = "class='" . join( ' ', $class ) . "'"; |
|
| 1111 | + if ( ! empty($class)) |
|
| 1112 | + $class = "class='".join(' ', $class)."'"; |
|
| 1113 | 1113 | |
| 1114 | 1114 | echo "<$tag $scope $id $class>$column_display_name</$tag>"; |
| 1115 | 1115 | } |
@@ -1124,11 +1124,11 @@ discard block |
||
| 1124 | 1124 | public function display() { |
| 1125 | 1125 | $singular = $this->_args['singular']; |
| 1126 | 1126 | |
| 1127 | - $this->display_tablenav( 'top' ); |
|
| 1127 | + $this->display_tablenav('top'); |
|
| 1128 | 1128 | |
| 1129 | - $this->screen->render_screen_reader_content( 'heading_list' ); |
|
| 1129 | + $this->screen->render_screen_reader_content('heading_list'); |
|
| 1130 | 1130 | ?> |
| 1131 | -<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> |
|
| 1131 | +<table class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>"> |
|
| 1132 | 1132 | <thead> |
| 1133 | 1133 | <tr> |
| 1134 | 1134 | <?php $this->print_column_headers(); ?> |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | </thead> |
| 1137 | 1137 | |
| 1138 | 1138 | <tbody id="the-list"<?php |
| 1139 | - if ( $singular ) { |
|
| 1139 | + if ($singular) { |
|
| 1140 | 1140 | echo " data-wp-lists='list:$singular'"; |
| 1141 | 1141 | } ?>> |
| 1142 | 1142 | <?php $this->display_rows_or_placeholder(); ?> |
@@ -1144,13 +1144,13 @@ discard block |
||
| 1144 | 1144 | |
| 1145 | 1145 | <tfoot> |
| 1146 | 1146 | <tr> |
| 1147 | - <?php $this->print_column_headers( false ); ?> |
|
| 1147 | + <?php $this->print_column_headers(false); ?> |
|
| 1148 | 1148 | </tr> |
| 1149 | 1149 | </tfoot> |
| 1150 | 1150 | |
| 1151 | 1151 | </table> |
| 1152 | 1152 | <?php |
| 1153 | - $this->display_tablenav( 'bottom' ); |
|
| 1153 | + $this->display_tablenav('bottom'); |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | /** |
@@ -1162,7 +1162,7 @@ discard block |
||
| 1162 | 1162 | * @return array List of CSS classes for the table tag. |
| 1163 | 1163 | */ |
| 1164 | 1164 | protected function get_table_classes() { |
| 1165 | - return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] ); |
|
| 1165 | + return array('widefat', 'fixed', 'striped', $this->_args['plural']); |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | /** |
@@ -1172,20 +1172,20 @@ discard block |
||
| 1172 | 1172 | * @access protected |
| 1173 | 1173 | * @param string $which |
| 1174 | 1174 | */ |
| 1175 | - protected function display_tablenav( $which ) { |
|
| 1176 | - if ( 'top' === $which ) { |
|
| 1177 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
| 1175 | + protected function display_tablenav($which) { |
|
| 1176 | + if ('top' === $which) { |
|
| 1177 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
| 1178 | 1178 | } |
| 1179 | 1179 | ?> |
| 1180 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
| 1180 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
| 1181 | 1181 | |
| 1182 | - <?php if ( $this->has_items() ): ?> |
|
| 1182 | + <?php if ($this->has_items()): ?> |
|
| 1183 | 1183 | <div class="alignleft actions bulkactions"> |
| 1184 | - <?php $this->bulk_actions( $which ); ?> |
|
| 1184 | + <?php $this->bulk_actions($which); ?> |
|
| 1185 | 1185 | </div> |
| 1186 | 1186 | <?php endif; |
| 1187 | - $this->extra_tablenav( $which ); |
|
| 1188 | - $this->pagination( $which ); |
|
| 1187 | + $this->extra_tablenav($which); |
|
| 1188 | + $this->pagination($which); |
|
| 1189 | 1189 | ?> |
| 1190 | 1190 | |
| 1191 | 1191 | <br class="clear" /> |
@@ -1201,7 +1201,7 @@ discard block |
||
| 1201 | 1201 | * |
| 1202 | 1202 | * @param string $which |
| 1203 | 1203 | */ |
| 1204 | - protected function extra_tablenav( $which ) {} |
|
| 1204 | + protected function extra_tablenav($which) {} |
|
| 1205 | 1205 | |
| 1206 | 1206 | /** |
| 1207 | 1207 | * Generate the tbody element for the list table. |
@@ -1210,10 +1210,10 @@ discard block |
||
| 1210 | 1210 | * @access public |
| 1211 | 1211 | */ |
| 1212 | 1212 | public function display_rows_or_placeholder() { |
| 1213 | - if ( $this->has_items() ) { |
|
| 1213 | + if ($this->has_items()) { |
|
| 1214 | 1214 | $this->display_rows(); |
| 1215 | 1215 | } else { |
| 1216 | - echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">'; |
|
| 1216 | + echo '<tr class="no-items"><td class="colspanchange" colspan="'.$this->get_column_count().'">'; |
|
| 1217 | 1217 | $this->no_items(); |
| 1218 | 1218 | echo '</td></tr>'; |
| 1219 | 1219 | } |
@@ -1226,8 +1226,8 @@ discard block |
||
| 1226 | 1226 | * @access public |
| 1227 | 1227 | */ |
| 1228 | 1228 | public function display_rows() { |
| 1229 | - foreach ( $this->items as $item ) |
|
| 1230 | - $this->single_row( $item ); |
|
| 1229 | + foreach ($this->items as $item) |
|
| 1230 | + $this->single_row($item); |
|
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | 1233 | /** |
@@ -1238,9 +1238,9 @@ discard block |
||
| 1238 | 1238 | * |
| 1239 | 1239 | * @param object $item The current item |
| 1240 | 1240 | */ |
| 1241 | - public function single_row( $item ) { |
|
| 1241 | + public function single_row($item) { |
|
| 1242 | 1242 | echo '<tr>'; |
| 1243 | - $this->single_row_columns( $item ); |
|
| 1243 | + $this->single_row_columns($item); |
|
| 1244 | 1244 | echo '</tr>'; |
| 1245 | 1245 | } |
| 1246 | 1246 | |
@@ -1249,13 +1249,13 @@ discard block |
||
| 1249 | 1249 | * @param object $item |
| 1250 | 1250 | * @param string $column_name |
| 1251 | 1251 | */ |
| 1252 | - protected function column_default( $item, $column_name ) {} |
|
| 1252 | + protected function column_default($item, $column_name) {} |
|
| 1253 | 1253 | |
| 1254 | 1254 | /** |
| 1255 | 1255 | * |
| 1256 | 1256 | * @param object $item |
| 1257 | 1257 | */ |
| 1258 | - protected function column_cb( $item ) {} |
|
| 1258 | + protected function column_cb($item) {} |
|
| 1259 | 1259 | |
| 1260 | 1260 | /** |
| 1261 | 1261 | * Generates the columns for a single row of the table |
@@ -1265,46 +1265,46 @@ discard block |
||
| 1265 | 1265 | * |
| 1266 | 1266 | * @param object $item The current item |
| 1267 | 1267 | */ |
| 1268 | - protected function single_row_columns( $item ) { |
|
| 1269 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
| 1268 | + protected function single_row_columns($item) { |
|
| 1269 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
| 1270 | 1270 | |
| 1271 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
| 1271 | + foreach ($columns as $column_name => $column_display_name) { |
|
| 1272 | 1272 | $classes = "$column_name column-$column_name"; |
| 1273 | - if ( $primary === $column_name ) { |
|
| 1273 | + if ($primary === $column_name) { |
|
| 1274 | 1274 | $classes .= ' has-row-actions column-primary'; |
| 1275 | 1275 | } |
| 1276 | 1276 | |
| 1277 | - if ( in_array( $column_name, $hidden ) ) { |
|
| 1277 | + if (in_array($column_name, $hidden)) { |
|
| 1278 | 1278 | $classes .= ' hidden'; |
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | // Comments column uses HTML in the display name with screen reader text. |
| 1282 | 1282 | // Instead of using esc_attr(), we strip tags to get closer to a user-friendly string. |
| 1283 | - $data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"'; |
|
| 1283 | + $data = 'data-colname="'.wp_strip_all_tags($column_display_name).'"'; |
|
| 1284 | 1284 | |
| 1285 | 1285 | $attributes = "class='$classes' $data"; |
| 1286 | 1286 | |
| 1287 | - if ( 'cb' === $column_name ) { |
|
| 1287 | + if ('cb' === $column_name) { |
|
| 1288 | 1288 | echo '<th scope="row" class="check-column">'; |
| 1289 | - echo $this->column_cb( $item ); |
|
| 1289 | + echo $this->column_cb($item); |
|
| 1290 | 1290 | echo '</th>'; |
| 1291 | - } elseif ( method_exists( $this, '_column_' . $column_name ) ) { |
|
| 1291 | + } elseif (method_exists($this, '_column_'.$column_name)) { |
|
| 1292 | 1292 | echo call_user_func( |
| 1293 | - array( $this, '_column_' . $column_name ), |
|
| 1293 | + array($this, '_column_'.$column_name), |
|
| 1294 | 1294 | $item, |
| 1295 | 1295 | $classes, |
| 1296 | 1296 | $data, |
| 1297 | 1297 | $primary |
| 1298 | 1298 | ); |
| 1299 | - } elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
|
| 1299 | + } elseif (method_exists($this, 'column_'.$column_name)) { |
|
| 1300 | 1300 | echo "<td $attributes>"; |
| 1301 | - echo call_user_func( array( $this, 'column_' . $column_name ), $item ); |
|
| 1302 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
| 1301 | + echo call_user_func(array($this, 'column_'.$column_name), $item); |
|
| 1302 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
| 1303 | 1303 | echo "</td>"; |
| 1304 | 1304 | } else { |
| 1305 | 1305 | echo "<td $attributes>"; |
| 1306 | - echo $this->column_default( $item, $column_name ); |
|
| 1307 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
| 1306 | + echo $this->column_default($item, $column_name); |
|
| 1307 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
| 1308 | 1308 | echo "</td>"; |
| 1309 | 1309 | } |
| 1310 | 1310 | } |
@@ -1321,8 +1321,8 @@ discard block |
||
| 1321 | 1321 | * @param string $primary Primary column name. |
| 1322 | 1322 | * @return string The row actions HTML, or an empty string if the current column is the primary column. |
| 1323 | 1323 | */ |
| 1324 | - protected function handle_row_actions( $item, $column_name, $primary ) { |
|
| 1325 | - return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>' : ''; |
|
| 1324 | + protected function handle_row_actions($item, $column_name, $primary) { |
|
| 1325 | + return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">'.__('Show more details').'</span></button>' : ''; |
|
| 1326 | 1326 | } |
| 1327 | 1327 | |
| 1328 | 1328 | /** |
@@ -1335,7 +1335,7 @@ discard block |
||
| 1335 | 1335 | $this->prepare_items(); |
| 1336 | 1336 | |
| 1337 | 1337 | ob_start(); |
| 1338 | - if ( ! empty( $_REQUEST['no_placeholder'] ) ) { |
|
| 1338 | + if ( ! empty($_REQUEST['no_placeholder'])) { |
|
| 1339 | 1339 | $this->display_rows(); |
| 1340 | 1340 | } else { |
| 1341 | 1341 | $this->display_rows_or_placeholder(); |
@@ -1343,20 +1343,20 @@ discard block |
||
| 1343 | 1343 | |
| 1344 | 1344 | $rows = ob_get_clean(); |
| 1345 | 1345 | |
| 1346 | - $response = array( 'rows' => $rows ); |
|
| 1346 | + $response = array('rows' => $rows); |
|
| 1347 | 1347 | |
| 1348 | - if ( isset( $this->_pagination_args['total_items'] ) ) { |
|
| 1348 | + if (isset($this->_pagination_args['total_items'])) { |
|
| 1349 | 1349 | $response['total_items_i18n'] = sprintf( |
| 1350 | - _n( '%s item', '%s items', $this->_pagination_args['total_items'] ), |
|
| 1351 | - number_format_i18n( $this->_pagination_args['total_items'] ) |
|
| 1350 | + _n('%s item', '%s items', $this->_pagination_args['total_items']), |
|
| 1351 | + number_format_i18n($this->_pagination_args['total_items']) |
|
| 1352 | 1352 | ); |
| 1353 | 1353 | } |
| 1354 | - if ( isset( $this->_pagination_args['total_pages'] ) ) { |
|
| 1354 | + if (isset($this->_pagination_args['total_pages'])) { |
|
| 1355 | 1355 | $response['total_pages'] = $this->_pagination_args['total_pages']; |
| 1356 | - $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] ); |
|
| 1356 | + $response['total_pages_i18n'] = number_format_i18n($this->_pagination_args['total_pages']); |
|
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | - die( wp_json_encode( $response ) ); |
|
| 1359 | + die(wp_json_encode($response)); |
|
| 1360 | 1360 | } |
| 1361 | 1361 | |
| 1362 | 1362 | /** |
@@ -1366,13 +1366,13 @@ discard block |
||
| 1366 | 1366 | */ |
| 1367 | 1367 | public function _js_vars() { |
| 1368 | 1368 | $args = array( |
| 1369 | - 'class' => get_class( $this ), |
|
| 1369 | + 'class' => get_class($this), |
|
| 1370 | 1370 | 'screen' => array( |
| 1371 | 1371 | 'id' => $this->screen->id, |
| 1372 | 1372 | 'base' => $this->screen->base, |
| 1373 | 1373 | ) |
| 1374 | 1374 | ); |
| 1375 | 1375 | |
| 1376 | - printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) ); |
|
| 1376 | + printf("<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode($args)); |
|
| 1377 | 1377 | } |
| 1378 | 1378 | } |
@@ -20,80 +20,80 @@ discard block |
||
| 20 | 20 | function delete_theme($stylesheet, $redirect = '') { |
| 21 | 21 | global $wp_filesystem; |
| 22 | 22 | |
| 23 | - if ( empty($stylesheet) ) |
|
| 23 | + if (empty($stylesheet)) |
|
| 24 | 24 | return false; |
| 25 | 25 | |
| 26 | - if ( empty( $redirect ) ) { |
|
| 27 | - $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet); |
|
| 26 | + if (empty($redirect)) { |
|
| 27 | + $redirect = wp_nonce_url('themes.php?action=delete&stylesheet='.urlencode($stylesheet), 'delete-theme_'.$stylesheet); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | ob_start(); |
| 31 | - $credentials = request_filesystem_credentials( $redirect ); |
|
| 31 | + $credentials = request_filesystem_credentials($redirect); |
|
| 32 | 32 | $data = ob_get_clean(); |
| 33 | 33 | |
| 34 | - if ( false === $credentials ) { |
|
| 35 | - if ( ! empty( $data ) ){ |
|
| 36 | - include_once( ABSPATH . 'wp-admin/admin-header.php'); |
|
| 34 | + if (false === $credentials) { |
|
| 35 | + if ( ! empty($data)) { |
|
| 36 | + include_once(ABSPATH.'wp-admin/admin-header.php'); |
|
| 37 | 37 | echo $data; |
| 38 | - include( ABSPATH . 'wp-admin/admin-footer.php'); |
|
| 38 | + include(ABSPATH.'wp-admin/admin-footer.php'); |
|
| 39 | 39 | exit; |
| 40 | 40 | } |
| 41 | 41 | return; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if ( ! WP_Filesystem( $credentials ) ) { |
|
| 44 | + if ( ! WP_Filesystem($credentials)) { |
|
| 45 | 45 | ob_start(); |
| 46 | - request_filesystem_credentials( $redirect, '', true ); // Failed to connect, Error and request again. |
|
| 46 | + request_filesystem_credentials($redirect, '', true); // Failed to connect, Error and request again. |
|
| 47 | 47 | $data = ob_get_clean(); |
| 48 | 48 | |
| 49 | - if ( ! empty($data) ) { |
|
| 50 | - include_once( ABSPATH . 'wp-admin/admin-header.php'); |
|
| 49 | + if ( ! empty($data)) { |
|
| 50 | + include_once(ABSPATH.'wp-admin/admin-header.php'); |
|
| 51 | 51 | echo $data; |
| 52 | - include( ABSPATH . 'wp-admin/admin-footer.php'); |
|
| 52 | + include(ABSPATH.'wp-admin/admin-footer.php'); |
|
| 53 | 53 | exit; |
| 54 | 54 | } |
| 55 | 55 | return; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if ( ! is_object($wp_filesystem) ) |
|
| 58 | + if ( ! is_object($wp_filesystem)) |
|
| 59 | 59 | return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
| 60 | 60 | |
| 61 | - if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) |
|
| 61 | + if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) |
|
| 62 | 62 | return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors); |
| 63 | 63 | |
| 64 | 64 | // Get the base plugin folder. |
| 65 | 65 | $themes_dir = $wp_filesystem->wp_themes_dir(); |
| 66 | - if ( empty( $themes_dir ) ) { |
|
| 67 | - return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) ); |
|
| 66 | + if (empty($themes_dir)) { |
|
| 67 | + return new WP_Error('fs_no_themes_dir', __('Unable to locate WordPress theme directory.')); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - $themes_dir = trailingslashit( $themes_dir ); |
|
| 71 | - $theme_dir = trailingslashit( $themes_dir . $stylesheet ); |
|
| 72 | - $deleted = $wp_filesystem->delete( $theme_dir, true ); |
|
| 70 | + $themes_dir = trailingslashit($themes_dir); |
|
| 71 | + $theme_dir = trailingslashit($themes_dir.$stylesheet); |
|
| 72 | + $deleted = $wp_filesystem->delete($theme_dir, true); |
|
| 73 | 73 | |
| 74 | - if ( ! $deleted ) { |
|
| 75 | - return new WP_Error( 'could_not_remove_theme', sprintf( __( 'Could not fully remove the theme %s.' ), $stylesheet ) ); |
|
| 74 | + if ( ! $deleted) { |
|
| 75 | + return new WP_Error('could_not_remove_theme', sprintf(__('Could not fully remove the theme %s.'), $stylesheet)); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $theme_translations = wp_get_installed_translations( 'themes' ); |
|
| 78 | + $theme_translations = wp_get_installed_translations('themes'); |
|
| 79 | 79 | |
| 80 | 80 | // Remove language files, silently. |
| 81 | - if ( ! empty( $theme_translations[ $stylesheet ] ) ) { |
|
| 82 | - $translations = $theme_translations[ $stylesheet ]; |
|
| 81 | + if ( ! empty($theme_translations[$stylesheet])) { |
|
| 82 | + $translations = $theme_translations[$stylesheet]; |
|
| 83 | 83 | |
| 84 | - foreach ( $translations as $translation => $data ) { |
|
| 85 | - $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.po' ); |
|
| 86 | - $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.mo' ); |
|
| 84 | + foreach ($translations as $translation => $data) { |
|
| 85 | + $wp_filesystem->delete(WP_LANG_DIR.'/themes/'.$stylesheet.'-'.$translation.'.po'); |
|
| 86 | + $wp_filesystem->delete(WP_LANG_DIR.'/themes/'.$stylesheet.'-'.$translation.'.mo'); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // Remove the theme from allowed themes on the network. |
| 91 | - if ( is_multisite() ) { |
|
| 92 | - WP_Theme::network_disable_theme( $stylesheet ); |
|
| 91 | + if (is_multisite()) { |
|
| 92 | + WP_Theme::network_disable_theme($stylesheet); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Force refresh of theme update information. |
| 96 | - delete_site_transient( 'update_themes' ); |
|
| 96 | + delete_site_transient('update_themes'); |
|
| 97 | 97 | |
| 98 | 98 | return true; |
| 99 | 99 | } |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | * @param WP_Post|null $post Optional. The post being edited, provided for context. |
| 107 | 107 | * @return array Key is the template name, value is the filename of the template |
| 108 | 108 | */ |
| 109 | -function get_page_templates( $post = null ) { |
|
| 110 | - return array_flip( wp_get_theme()->get_page_templates( $post ) ); |
|
| 109 | +function get_page_templates($post = null) { |
|
| 110 | + return array_flip(wp_get_theme()->get_page_templates($post)); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @return string |
| 122 | 122 | */ |
| 123 | 123 | function _get_template_edit_filename($fullpath, $containingfolder) { |
| 124 | - return str_replace(dirname(dirname( $containingfolder )) , '', $fullpath); |
|
| 124 | + return str_replace(dirname(dirname($containingfolder)), '', $fullpath); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | * |
| 135 | 135 | * @param WP_Theme $theme Theme data object. |
| 136 | 136 | */ |
| 137 | -function theme_update_available( $theme ) { |
|
| 138 | - echo get_theme_update_available( $theme ); |
|
| 137 | +function theme_update_available($theme) { |
|
| 138 | + echo get_theme_update_available($theme); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -150,16 +150,16 @@ discard block |
||
| 150 | 150 | * @param WP_Theme $theme WP_Theme object. |
| 151 | 151 | * @return false|string HTML for the update link, or false if invalid info was passed. |
| 152 | 152 | */ |
| 153 | -function get_theme_update_available( $theme ) { |
|
| 153 | +function get_theme_update_available($theme) { |
|
| 154 | 154 | static $themes_update = null; |
| 155 | 155 | |
| 156 | - if ( !current_user_can('update_themes' ) ) |
|
| 156 | + if ( ! current_user_can('update_themes')) |
|
| 157 | 157 | return false; |
| 158 | 158 | |
| 159 | - if ( !isset($themes_update) ) |
|
| 159 | + if ( ! isset($themes_update)) |
|
| 160 | 160 | $themes_update = get_site_transient('update_themes'); |
| 161 | 161 | |
| 162 | - if ( ! ( $theme instanceof WP_Theme ) ) { |
|
| 162 | + if ( ! ($theme instanceof WP_Theme)) { |
|
| 163 | 163 | return false; |
| 164 | 164 | } |
| 165 | 165 | |
@@ -167,49 +167,49 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | $html = ''; |
| 169 | 169 | |
| 170 | - if ( isset($themes_update->response[ $stylesheet ]) ) { |
|
| 171 | - $update = $themes_update->response[ $stylesheet ]; |
|
| 170 | + if (isset($themes_update->response[$stylesheet])) { |
|
| 171 | + $update = $themes_update->response[$stylesheet]; |
|
| 172 | 172 | $theme_name = $theme->display('Name'); |
| 173 | 173 | $details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']); //Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list. |
| 174 | - $update_url = wp_nonce_url( admin_url( 'update.php?action=upgrade-theme&theme=' . urlencode( $stylesheet ) ), 'upgrade-theme_' . $stylesheet ); |
|
| 174 | + $update_url = wp_nonce_url(admin_url('update.php?action=upgrade-theme&theme='.urlencode($stylesheet)), 'upgrade-theme_'.$stylesheet); |
|
| 175 | 175 | |
| 176 | - if ( !is_multisite() ) { |
|
| 177 | - if ( ! current_user_can('update_themes') ) { |
|
| 176 | + if ( ! is_multisite()) { |
|
| 177 | + if ( ! current_user_can('update_themes')) { |
|
| 178 | 178 | /* translators: 1: theme name, 2: theme details URL, 3: additional link attributes, 4: version number */ |
| 179 | - $html = sprintf( '<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ) . '</strong></p>', |
|
| 179 | + $html = sprintf('<p><strong>'.__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.').'</strong></p>', |
|
| 180 | 180 | $theme_name, |
| 181 | - esc_url( $details_url ), |
|
| 182 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 181 | + esc_url($details_url), |
|
| 182 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 183 | 183 | /* translators: 1: theme name, 2: version number */ |
| 184 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) ) |
|
| 184 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $update['new_version'])) |
|
| 185 | 185 | ), |
| 186 | 186 | $update['new_version'] |
| 187 | 187 | ); |
| 188 | - } elseif ( empty( $update['package'] ) ) { |
|
| 188 | + } elseif (empty($update['package'])) { |
|
| 189 | 189 | /* translators: 1: theme name, 2: theme details URL, 3: additional link attributes, 4: version number */ |
| 190 | - $html = sprintf( '<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ) . '</strong></p>', |
|
| 190 | + $html = sprintf('<p><strong>'.__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>').'</strong></p>', |
|
| 191 | 191 | $theme_name, |
| 192 | - esc_url( $details_url ), |
|
| 193 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 192 | + esc_url($details_url), |
|
| 193 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 194 | 194 | /* translators: 1: theme name, 2: version number */ |
| 195 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) ) |
|
| 195 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $update['new_version'])) |
|
| 196 | 196 | ), |
| 197 | 197 | $update['new_version'] |
| 198 | 198 | ); |
| 199 | 199 | } else { |
| 200 | 200 | /* translators: 1: theme name, 2: theme details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */ |
| 201 | - $html = sprintf( '<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ) . '</strong></p>', |
|
| 201 | + $html = sprintf('<p><strong>'.__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.').'</strong></p>', |
|
| 202 | 202 | $theme_name, |
| 203 | - esc_url( $details_url ), |
|
| 204 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 203 | + esc_url($details_url), |
|
| 204 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 205 | 205 | /* translators: 1: theme name, 2: version number */ |
| 206 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) ) |
|
| 206 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $theme_name, $update['new_version'])) |
|
| 207 | 207 | ), |
| 208 | 208 | $update['new_version'], |
| 209 | 209 | $update_url, |
| 210 | - sprintf( 'aria-label="%s" id="update-theme" data-slug="%s"', |
|
| 210 | + sprintf('aria-label="%s" id="update-theme" data-slug="%s"', |
|
| 211 | 211 | /* translators: %s: theme name */ |
| 212 | - esc_attr( sprintf( __( 'Update %s now' ), $theme_name ) ), |
|
| 212 | + esc_attr(sprintf(__('Update %s now'), $theme_name)), |
|
| 213 | 213 | $stylesheet |
| 214 | 214 | ) |
| 215 | 215 | ); |
@@ -228,89 +228,89 @@ discard block |
||
| 228 | 228 | * @param bool $api Optional. Whether try to fetch tags from the WordPress.org API. Defaults to true. |
| 229 | 229 | * @return array Array of features keyed by category with translations keyed by slug. |
| 230 | 230 | */ |
| 231 | -function get_theme_feature_list( $api = true ) { |
|
| 231 | +function get_theme_feature_list($api = true) { |
|
| 232 | 232 | // Hard-coded list is used if api not accessible. |
| 233 | 233 | $features = array( |
| 234 | 234 | |
| 235 | - __( 'Layout' ) => array( |
|
| 236 | - 'grid-layout' => __( 'Grid Layout' ), |
|
| 237 | - 'one-column' => __( 'One Column' ), |
|
| 238 | - 'two-columns' => __( 'Two Columns' ), |
|
| 239 | - 'three-columns' => __( 'Three Columns' ), |
|
| 240 | - 'four-columns' => __( 'Four Columns' ), |
|
| 241 | - 'left-sidebar' => __( 'Left Sidebar' ), |
|
| 242 | - 'right-sidebar' => __( 'Right Sidebar' ), |
|
| 235 | + __('Layout') => array( |
|
| 236 | + 'grid-layout' => __('Grid Layout'), |
|
| 237 | + 'one-column' => __('One Column'), |
|
| 238 | + 'two-columns' => __('Two Columns'), |
|
| 239 | + 'three-columns' => __('Three Columns'), |
|
| 240 | + 'four-columns' => __('Four Columns'), |
|
| 241 | + 'left-sidebar' => __('Left Sidebar'), |
|
| 242 | + 'right-sidebar' => __('Right Sidebar'), |
|
| 243 | 243 | ), |
| 244 | 244 | |
| 245 | - __( 'Features' ) => array( |
|
| 246 | - 'accessibility-ready' => __( 'Accessibility Ready' ), |
|
| 247 | - 'buddypress' => __( 'BuddyPress' ), |
|
| 248 | - 'custom-background' => __( 'Custom Background' ), |
|
| 249 | - 'custom-colors' => __( 'Custom Colors' ), |
|
| 250 | - 'custom-header' => __( 'Custom Header' ), |
|
| 251 | - 'custom-logo' => __( 'Custom Logo' ), |
|
| 252 | - 'custom-menu' => __( 'Custom Menu' ), |
|
| 253 | - 'editor-style' => __( 'Editor Style' ), |
|
| 254 | - 'featured-image-header' => __( 'Featured Image Header' ), |
|
| 255 | - 'featured-images' => __( 'Featured Images' ), |
|
| 256 | - 'flexible-header' => __( 'Flexible Header' ), |
|
| 257 | - 'footer-widgets' => __( 'Footer Widgets' ), |
|
| 258 | - 'front-page-post-form' => __( 'Front Page Posting' ), |
|
| 259 | - 'full-width-template' => __( 'Full Width Template' ), |
|
| 260 | - 'microformats' => __( 'Microformats' ), |
|
| 261 | - 'post-formats' => __( 'Post Formats' ), |
|
| 262 | - 'rtl-language-support' => __( 'RTL Language Support' ), |
|
| 263 | - 'sticky-post' => __( 'Sticky Post' ), |
|
| 264 | - 'theme-options' => __( 'Theme Options' ), |
|
| 265 | - 'threaded-comments' => __( 'Threaded Comments' ), |
|
| 266 | - 'translation-ready' => __( 'Translation Ready' ), |
|
| 245 | + __('Features') => array( |
|
| 246 | + 'accessibility-ready' => __('Accessibility Ready'), |
|
| 247 | + 'buddypress' => __('BuddyPress'), |
|
| 248 | + 'custom-background' => __('Custom Background'), |
|
| 249 | + 'custom-colors' => __('Custom Colors'), |
|
| 250 | + 'custom-header' => __('Custom Header'), |
|
| 251 | + 'custom-logo' => __('Custom Logo'), |
|
| 252 | + 'custom-menu' => __('Custom Menu'), |
|
| 253 | + 'editor-style' => __('Editor Style'), |
|
| 254 | + 'featured-image-header' => __('Featured Image Header'), |
|
| 255 | + 'featured-images' => __('Featured Images'), |
|
| 256 | + 'flexible-header' => __('Flexible Header'), |
|
| 257 | + 'footer-widgets' => __('Footer Widgets'), |
|
| 258 | + 'front-page-post-form' => __('Front Page Posting'), |
|
| 259 | + 'full-width-template' => __('Full Width Template'), |
|
| 260 | + 'microformats' => __('Microformats'), |
|
| 261 | + 'post-formats' => __('Post Formats'), |
|
| 262 | + 'rtl-language-support' => __('RTL Language Support'), |
|
| 263 | + 'sticky-post' => __('Sticky Post'), |
|
| 264 | + 'theme-options' => __('Theme Options'), |
|
| 265 | + 'threaded-comments' => __('Threaded Comments'), |
|
| 266 | + 'translation-ready' => __('Translation Ready'), |
|
| 267 | 267 | ), |
| 268 | 268 | |
| 269 | - __( 'Subject' ) => array( |
|
| 270 | - 'blog' => __( 'Blog' ), |
|
| 271 | - 'e-commerce' => __( 'E-Commerce' ), |
|
| 272 | - 'education' => __( 'Education' ), |
|
| 273 | - 'entertainment' => __( 'Entertainment' ), |
|
| 274 | - 'food-and-drink' => __( 'Food & Drink' ), |
|
| 275 | - 'holiday' => __( 'Holiday' ), |
|
| 276 | - 'news' => __( 'News' ), |
|
| 277 | - 'photography' => __( 'Photography' ), |
|
| 278 | - 'portfolio' => __( 'Portfolio' ), |
|
| 269 | + __('Subject') => array( |
|
| 270 | + 'blog' => __('Blog'), |
|
| 271 | + 'e-commerce' => __('E-Commerce'), |
|
| 272 | + 'education' => __('Education'), |
|
| 273 | + 'entertainment' => __('Entertainment'), |
|
| 274 | + 'food-and-drink' => __('Food & Drink'), |
|
| 275 | + 'holiday' => __('Holiday'), |
|
| 276 | + 'news' => __('News'), |
|
| 277 | + 'photography' => __('Photography'), |
|
| 278 | + 'portfolio' => __('Portfolio'), |
|
| 279 | 279 | ) |
| 280 | 280 | ); |
| 281 | 281 | |
| 282 | - if ( ! $api || ! current_user_can( 'install_themes' ) ) |
|
| 282 | + if ( ! $api || ! current_user_can('install_themes')) |
|
| 283 | 283 | return $features; |
| 284 | 284 | |
| 285 | - if ( !$feature_list = get_site_transient( 'wporg_theme_feature_list' ) ) |
|
| 286 | - set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS ); |
|
| 285 | + if ( ! $feature_list = get_site_transient('wporg_theme_feature_list')) |
|
| 286 | + set_site_transient('wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS); |
|
| 287 | 287 | |
| 288 | - if ( !$feature_list ) { |
|
| 289 | - $feature_list = themes_api( 'feature_list', array() ); |
|
| 290 | - if ( is_wp_error( $feature_list ) ) |
|
| 288 | + if ( ! $feature_list) { |
|
| 289 | + $feature_list = themes_api('feature_list', array()); |
|
| 290 | + if (is_wp_error($feature_list)) |
|
| 291 | 291 | return $features; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - if ( !$feature_list ) |
|
| 294 | + if ( ! $feature_list) |
|
| 295 | 295 | return $features; |
| 296 | 296 | |
| 297 | - set_site_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS ); |
|
| 297 | + set_site_transient('wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS); |
|
| 298 | 298 | |
| 299 | 299 | $category_translations = array( |
| 300 | - 'Layout' => __( 'Layout' ), |
|
| 301 | - 'Features' => __( 'Features' ), |
|
| 302 | - 'Subject' => __( 'Subject' ), |
|
| 300 | + 'Layout' => __('Layout'), |
|
| 301 | + 'Features' => __('Features'), |
|
| 302 | + 'Subject' => __('Subject'), |
|
| 303 | 303 | ); |
| 304 | 304 | |
| 305 | 305 | // Loop over the wporg canonical list and apply translations |
| 306 | 306 | $wporg_features = array(); |
| 307 | - foreach ( (array) $feature_list as $feature_category => $feature_items ) { |
|
| 308 | - if ( isset($category_translations[$feature_category]) ) |
|
| 307 | + foreach ((array) $feature_list as $feature_category => $feature_items) { |
|
| 308 | + if (isset($category_translations[$feature_category])) |
|
| 309 | 309 | $feature_category = $category_translations[$feature_category]; |
| 310 | 310 | $wporg_features[$feature_category] = array(); |
| 311 | 311 | |
| 312 | - foreach ( $feature_items as $feature ) { |
|
| 313 | - if ( isset($features[$feature_category][$feature]) ) |
|
| 312 | + foreach ($feature_items as $feature) { |
|
| 313 | + if (isset($features[$feature_category][$feature])) |
|
| 314 | 314 | $wporg_features[$feature_category][$feature] = $features[$feature_category][$feature]; |
| 315 | 315 | else |
| 316 | 316 | $wporg_features[$feature_category][$feature] = $feature; |
@@ -401,17 +401,17 @@ discard block |
||
| 401 | 401 | * {@link https://developer.wordpress.org/reference/functions/themes_api/ function reference article} |
| 402 | 402 | * for more information on the make-up of possible return objects depending on the value of `$action`. |
| 403 | 403 | */ |
| 404 | -function themes_api( $action, $args = array() ) { |
|
| 404 | +function themes_api($action, $args = array()) { |
|
| 405 | 405 | |
| 406 | - if ( is_array( $args ) ) { |
|
| 406 | + if (is_array($args)) { |
|
| 407 | 407 | $args = (object) $args; |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - if ( ! isset( $args->per_page ) ) { |
|
| 410 | + if ( ! isset($args->per_page)) { |
|
| 411 | 411 | $args->per_page = 24; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - if ( ! isset( $args->locale ) ) { |
|
| 414 | + if ( ! isset($args->locale)) { |
|
| 415 | 415 | $args->locale = get_locale(); |
| 416 | 416 | } |
| 417 | 417 | |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | * @param string $action Requested action. Likely values are 'theme_information', |
| 427 | 427 | * 'feature_list', or 'query_themes'. |
| 428 | 428 | */ |
| 429 | - $args = apply_filters( 'themes_api_args', $args, $action ); |
|
| 429 | + $args = apply_filters('themes_api_args', $args, $action); |
|
| 430 | 430 | |
| 431 | 431 | /** |
| 432 | 432 | * Filters whether to override the WordPress.org Themes API. |
@@ -443,34 +443,34 @@ discard block |
||
| 443 | 443 | * 'feature_list', or 'query_themes'. |
| 444 | 444 | * @param object $args Arguments used to query for installer pages from the Themes API. |
| 445 | 445 | */ |
| 446 | - $res = apply_filters( 'themes_api', false, $action, $args ); |
|
| 446 | + $res = apply_filters('themes_api', false, $action, $args); |
|
| 447 | 447 | |
| 448 | - if ( ! $res ) { |
|
| 448 | + if ( ! $res) { |
|
| 449 | 449 | $url = $http_url = 'http://api.wordpress.org/themes/info/1.0/'; |
| 450 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
| 451 | - $url = set_url_scheme( $url, 'https' ); |
|
| 450 | + if ($ssl = wp_http_supports(array('ssl'))) |
|
| 451 | + $url = set_url_scheme($url, 'https'); |
|
| 452 | 452 | |
| 453 | 453 | $http_args = array( |
| 454 | 454 | 'body' => array( |
| 455 | 455 | 'action' => $action, |
| 456 | - 'request' => serialize( $args ) |
|
| 456 | + 'request' => serialize($args) |
|
| 457 | 457 | ) |
| 458 | 458 | ); |
| 459 | - $request = wp_remote_post( $url, $http_args ); |
|
| 459 | + $request = wp_remote_post($url, $http_args); |
|
| 460 | 460 | |
| 461 | - if ( $ssl && is_wp_error( $request ) ) { |
|
| 462 | - if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) { |
|
| 463 | - trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); |
|
| 461 | + if ($ssl && is_wp_error($request)) { |
|
| 462 | + if ( ! defined('DOING_AJAX') || ! DOING_AJAX) { |
|
| 463 | + trigger_error(__('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.').' '.__('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE); |
|
| 464 | 464 | } |
| 465 | - $request = wp_remote_post( $http_url, $http_args ); |
|
| 465 | + $request = wp_remote_post($http_url, $http_args); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if ( is_wp_error($request) ) { |
|
| 469 | - $res = new WP_Error('themes_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() ); |
|
| 468 | + if (is_wp_error($request)) { |
|
| 469 | + $res = new WP_Error('themes_api_failed', __('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.'), $request->get_error_message()); |
|
| 470 | 470 | } else { |
| 471 | - $res = maybe_unserialize( wp_remote_retrieve_body( $request ) ); |
|
| 472 | - if ( ! is_object( $res ) && ! is_array( $res ) ) |
|
| 473 | - $res = new WP_Error('themes_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) ); |
|
| 471 | + $res = maybe_unserialize(wp_remote_retrieve_body($request)); |
|
| 472 | + if ( ! is_object($res) && ! is_array($res)) |
|
| 473 | + $res = new WP_Error('themes_api_failed', __('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.'), wp_remote_retrieve_body($request)); |
|
| 474 | 474 | } |
| 475 | 475 | } |
| 476 | 476 | |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | * 'feature_list', or 'query_themes'. |
| 485 | 485 | * @param object $args Arguments used to query for installer pages from the WordPress.org Themes API. |
| 486 | 486 | */ |
| 487 | - return apply_filters( 'themes_api_result', $res, $action, $args ); |
|
| 487 | + return apply_filters('themes_api_result', $res, $action, $args); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | /** |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | * |
| 498 | 498 | * @return array An associative array of theme data, sorted by name. |
| 499 | 499 | */ |
| 500 | -function wp_prepare_themes_for_js( $themes = null ) { |
|
| 500 | +function wp_prepare_themes_for_js($themes = null) { |
|
| 501 | 501 | $current_theme = get_stylesheet(); |
| 502 | 502 | |
| 503 | 503 | /** |
@@ -512,78 +512,78 @@ discard block |
||
| 512 | 512 | * @param null|array $themes An array of WP_Theme objects to prepare, if any. |
| 513 | 513 | * @param string $current_theme The current theme slug. |
| 514 | 514 | */ |
| 515 | - $prepared_themes = (array) apply_filters( 'pre_prepare_themes_for_js', array(), $themes, $current_theme ); |
|
| 515 | + $prepared_themes = (array) apply_filters('pre_prepare_themes_for_js', array(), $themes, $current_theme); |
|
| 516 | 516 | |
| 517 | - if ( ! empty( $prepared_themes ) ) { |
|
| 517 | + if ( ! empty($prepared_themes)) { |
|
| 518 | 518 | return $prepared_themes; |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | // Make sure the current theme is listed first. |
| 522 | - $prepared_themes[ $current_theme ] = array(); |
|
| 522 | + $prepared_themes[$current_theme] = array(); |
|
| 523 | 523 | |
| 524 | - if ( null === $themes ) { |
|
| 525 | - $themes = wp_get_themes( array( 'allowed' => true ) ); |
|
| 526 | - if ( ! isset( $themes[ $current_theme ] ) ) { |
|
| 527 | - $themes[ $current_theme ] = wp_get_theme(); |
|
| 524 | + if (null === $themes) { |
|
| 525 | + $themes = wp_get_themes(array('allowed' => true)); |
|
| 526 | + if ( ! isset($themes[$current_theme])) { |
|
| 527 | + $themes[$current_theme] = wp_get_theme(); |
|
| 528 | 528 | } |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | $updates = array(); |
| 532 | - if ( current_user_can( 'update_themes' ) ) { |
|
| 533 | - $updates_transient = get_site_transient( 'update_themes' ); |
|
| 534 | - if ( isset( $updates_transient->response ) ) { |
|
| 532 | + if (current_user_can('update_themes')) { |
|
| 533 | + $updates_transient = get_site_transient('update_themes'); |
|
| 534 | + if (isset($updates_transient->response)) { |
|
| 535 | 535 | $updates = $updates_transient->response; |
| 536 | 536 | } |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - WP_Theme::sort_by_name( $themes ); |
|
| 539 | + WP_Theme::sort_by_name($themes); |
|
| 540 | 540 | |
| 541 | 541 | $parents = array(); |
| 542 | 542 | |
| 543 | - foreach ( $themes as $theme ) { |
|
| 543 | + foreach ($themes as $theme) { |
|
| 544 | 544 | $slug = $theme->get_stylesheet(); |
| 545 | - $encoded_slug = urlencode( $slug ); |
|
| 545 | + $encoded_slug = urlencode($slug); |
|
| 546 | 546 | |
| 547 | 547 | $parent = false; |
| 548 | - if ( $theme->parent() ) { |
|
| 549 | - $parent = $theme->parent()->display( 'Name' ); |
|
| 550 | - $parents[ $slug ] = $theme->parent()->get_stylesheet(); |
|
| 548 | + if ($theme->parent()) { |
|
| 549 | + $parent = $theme->parent()->display('Name'); |
|
| 550 | + $parents[$slug] = $theme->parent()->get_stylesheet(); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | $customize_action = null; |
| 554 | - if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
|
| 555 | - $customize_action = esc_url( add_query_arg( |
|
| 554 | + if (current_user_can('edit_theme_options') && current_user_can('customize')) { |
|
| 555 | + $customize_action = esc_url(add_query_arg( |
|
| 556 | 556 | array( |
| 557 | - 'return' => urlencode( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), |
|
| 557 | + 'return' => urlencode(esc_url_raw(wp_unslash($_SERVER['REQUEST_URI']))), |
|
| 558 | 558 | ), |
| 559 | - wp_customize_url( $slug ) |
|
| 560 | - ) ); |
|
| 559 | + wp_customize_url($slug) |
|
| 560 | + )); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - $prepared_themes[ $slug ] = array( |
|
| 563 | + $prepared_themes[$slug] = array( |
|
| 564 | 564 | 'id' => $slug, |
| 565 | - 'name' => $theme->display( 'Name' ), |
|
| 566 | - 'screenshot' => array( $theme->get_screenshot() ), // @todo multiple |
|
| 567 | - 'description' => $theme->display( 'Description' ), |
|
| 568 | - 'author' => $theme->display( 'Author', false, true ), |
|
| 569 | - 'authorAndUri' => $theme->display( 'Author' ), |
|
| 570 | - 'version' => $theme->display( 'Version' ), |
|
| 571 | - 'tags' => $theme->display( 'Tags' ), |
|
| 565 | + 'name' => $theme->display('Name'), |
|
| 566 | + 'screenshot' => array($theme->get_screenshot()), // @todo multiple |
|
| 567 | + 'description' => $theme->display('Description'), |
|
| 568 | + 'author' => $theme->display('Author', false, true), |
|
| 569 | + 'authorAndUri' => $theme->display('Author'), |
|
| 570 | + 'version' => $theme->display('Version'), |
|
| 571 | + 'tags' => $theme->display('Tags'), |
|
| 572 | 572 | 'parent' => $parent, |
| 573 | 573 | 'active' => $slug === $current_theme, |
| 574 | - 'hasUpdate' => isset( $updates[ $slug ] ), |
|
| 575 | - 'update' => get_theme_update_available( $theme ), |
|
| 574 | + 'hasUpdate' => isset($updates[$slug]), |
|
| 575 | + 'update' => get_theme_update_available($theme), |
|
| 576 | 576 | 'actions' => array( |
| 577 | - 'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null, |
|
| 577 | + 'activate' => current_user_can('switch_themes') ? wp_nonce_url(admin_url('themes.php?action=activate&stylesheet='.$encoded_slug), 'switch-theme_'.$slug) : null, |
|
| 578 | 578 | 'customize' => $customize_action, |
| 579 | - 'delete' => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null, |
|
| 579 | + 'delete' => current_user_can('delete_themes') ? wp_nonce_url(admin_url('themes.php?action=delete&stylesheet='.$encoded_slug), 'delete-theme_'.$slug) : null, |
|
| 580 | 580 | ), |
| 581 | 581 | ); |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | // Remove 'delete' action if theme has an active child |
| 585 | - if ( ! empty( $parents ) && array_key_exists( $current_theme, $parents ) ) { |
|
| 586 | - unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] ); |
|
| 585 | + if ( ! empty($parents) && array_key_exists($current_theme, $parents)) { |
|
| 586 | + unset($prepared_themes[$parents[$current_theme]]['actions']['delete']); |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | /** |
@@ -595,9 +595,9 @@ discard block |
||
| 595 | 595 | * |
| 596 | 596 | * @param array $prepared_themes Array of themes. |
| 597 | 597 | */ |
| 598 | - $prepared_themes = apply_filters( 'wp_prepare_themes_for_js', $prepared_themes ); |
|
| 599 | - $prepared_themes = array_values( $prepared_themes ); |
|
| 600 | - return array_filter( $prepared_themes ); |
|
| 598 | + $prepared_themes = apply_filters('wp_prepare_themes_for_js', $prepared_themes); |
|
| 599 | + $prepared_themes = array_values($prepared_themes); |
|
| 600 | + return array_filter($prepared_themes); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | /** |
@@ -606,16 +606,16 @@ discard block |
||
| 606 | 606 | * @since 4.2.0 |
| 607 | 607 | */ |
| 608 | 608 | function customize_themes_print_templates() { |
| 609 | - $preview_url = esc_url( add_query_arg( 'theme', '__THEME__' ) ); // Token because esc_url() strips curly braces. |
|
| 610 | - $preview_url = str_replace( '__THEME__', '{{ data.id }}', $preview_url ); |
|
| 609 | + $preview_url = esc_url(add_query_arg('theme', '__THEME__')); // Token because esc_url() strips curly braces. |
|
| 610 | + $preview_url = str_replace('__THEME__', '{{ data.id }}', $preview_url); |
|
| 611 | 611 | ?> |
| 612 | 612 | <script type="text/html" id="tmpl-customize-themes-details-view"> |
| 613 | 613 | <div class="theme-backdrop"></div> |
| 614 | 614 | <div class="theme-wrap wp-clearfix"> |
| 615 | 615 | <div class="theme-header"> |
| 616 | - <button type="button" class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show previous theme' ); ?></span></button> |
|
| 617 | - <button type="button" class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show next theme' ); ?></span></button> |
|
| 618 | - <button type="button" class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close details dialog' ); ?></span></button> |
|
| 616 | + <button type="button" class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e('Show previous theme'); ?></span></button> |
|
| 617 | + <button type="button" class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e('Show next theme'); ?></span></button> |
|
| 618 | + <button type="button" class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e('Close details dialog'); ?></span></button> |
|
| 619 | 619 | </div> |
| 620 | 620 | <div class="theme-about wp-clearfix"> |
| 621 | 621 | <div class="theme-screenshots"> |
@@ -628,18 +628,18 @@ discard block |
||
| 628 | 628 | |
| 629 | 629 | <div class="theme-info"> |
| 630 | 630 | <# if ( data.active ) { #> |
| 631 | - <span class="current-label"><?php _e( 'Current Theme' ); ?></span> |
|
| 631 | + <span class="current-label"><?php _e('Current Theme'); ?></span> |
|
| 632 | 632 | <# } #> |
| 633 | - <h2 class="theme-name">{{{ data.name }}}<span class="theme-version"><?php printf( __( 'Version: %s' ), '{{ data.version }}' ); ?></span></h2> |
|
| 634 | - <h3 class="theme-author"><?php printf( __( 'By %s' ), '{{{ data.authorAndUri }}}' ); ?></h3> |
|
| 633 | + <h2 class="theme-name">{{{ data.name }}}<span class="theme-version"><?php printf(__('Version: %s'), '{{ data.version }}'); ?></span></h2> |
|
| 634 | + <h3 class="theme-author"><?php printf(__('By %s'), '{{{ data.authorAndUri }}}'); ?></h3> |
|
| 635 | 635 | <p class="theme-description">{{{ data.description }}}</p> |
| 636 | 636 | |
| 637 | 637 | <# if ( data.parent ) { #> |
| 638 | - <p class="parent-theme"><?php printf( __( 'This is a child theme of %s.' ), '<strong>{{{ data.parent }}}</strong>' ); ?></p> |
|
| 638 | + <p class="parent-theme"><?php printf(__('This is a child theme of %s.'), '<strong>{{{ data.parent }}}</strong>'); ?></p> |
|
| 639 | 639 | <# } #> |
| 640 | 640 | |
| 641 | 641 | <# if ( data.tags ) { #> |
| 642 | - <p class="theme-tags"><span><?php _e( 'Tags:' ); ?></span> {{ data.tags }}</p> |
|
| 642 | + <p class="theme-tags"><span><?php _e('Tags:'); ?></span> {{ data.tags }}</p> |
|
| 643 | 643 | <# } #> |
| 644 | 644 | </div> |
| 645 | 645 | </div> |
@@ -649,9 +649,9 @@ discard block |
||
| 649 | 649 | <div class="inactive-theme"> |
| 650 | 650 | <?php |
| 651 | 651 | /* translators: %s: Theme name */ |
| 652 | - $aria_label = sprintf( __( 'Preview %s' ), '{{ data.name }}' ); |
|
| 652 | + $aria_label = sprintf(__('Preview %s'), '{{ data.name }}'); |
|
| 653 | 653 | ?> |
| 654 | - <a href="<?php echo $preview_url; ?>" target="_top" class="button button-primary" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Live Preview' ); ?></a> |
|
| 654 | + <a href="<?php echo $preview_url; ?>" target="_top" class="button button-primary" aria-label="<?php echo esc_attr($aria_label); ?>"><?php _e('Live Preview'); ?></a> |
|
| 655 | 655 | </div> |
| 656 | 656 | </div> |
| 657 | 657 | <# } #> |
@@ -20,8 +20,9 @@ discard block |
||
| 20 | 20 | function delete_theme($stylesheet, $redirect = '') { |
| 21 | 21 | global $wp_filesystem; |
| 22 | 22 | |
| 23 | - if ( empty($stylesheet) ) |
|
| 24 | - return false; |
|
| 23 | + if ( empty($stylesheet) ) { |
|
| 24 | + return false; |
|
| 25 | + } |
|
| 25 | 26 | |
| 26 | 27 | if ( empty( $redirect ) ) { |
| 27 | 28 | $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet); |
@@ -55,11 +56,13 @@ discard block |
||
| 55 | 56 | return; |
| 56 | 57 | } |
| 57 | 58 | |
| 58 | - if ( ! is_object($wp_filesystem) ) |
|
| 59 | - return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
|
| 59 | + if ( ! is_object($wp_filesystem) ) { |
|
| 60 | + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
|
| 61 | + } |
|
| 60 | 62 | |
| 61 | - if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) |
|
| 62 | - return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors); |
|
| 63 | + if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) { |
|
| 64 | + return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors); |
|
| 65 | + } |
|
| 63 | 66 | |
| 64 | 67 | // Get the base plugin folder. |
| 65 | 68 | $themes_dir = $wp_filesystem->wp_themes_dir(); |
@@ -153,11 +156,13 @@ discard block |
||
| 153 | 156 | function get_theme_update_available( $theme ) { |
| 154 | 157 | static $themes_update = null; |
| 155 | 158 | |
| 156 | - if ( !current_user_can('update_themes' ) ) |
|
| 157 | - return false; |
|
| 159 | + if ( !current_user_can('update_themes' ) ) { |
|
| 160 | + return false; |
|
| 161 | + } |
|
| 158 | 162 | |
| 159 | - if ( !isset($themes_update) ) |
|
| 160 | - $themes_update = get_site_transient('update_themes'); |
|
| 163 | + if ( !isset($themes_update) ) { |
|
| 164 | + $themes_update = get_site_transient('update_themes'); |
|
| 165 | + } |
|
| 161 | 166 | |
| 162 | 167 | if ( ! ( $theme instanceof WP_Theme ) ) { |
| 163 | 168 | return false; |
@@ -279,20 +284,24 @@ discard block |
||
| 279 | 284 | ) |
| 280 | 285 | ); |
| 281 | 286 | |
| 282 | - if ( ! $api || ! current_user_can( 'install_themes' ) ) |
|
| 283 | - return $features; |
|
| 287 | + if ( ! $api || ! current_user_can( 'install_themes' ) ) { |
|
| 288 | + return $features; |
|
| 289 | + } |
|
| 284 | 290 | |
| 285 | - if ( !$feature_list = get_site_transient( 'wporg_theme_feature_list' ) ) |
|
| 286 | - set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS ); |
|
| 291 | + if ( !$feature_list = get_site_transient( 'wporg_theme_feature_list' ) ) { |
|
| 292 | + set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS ); |
|
| 293 | + } |
|
| 287 | 294 | |
| 288 | 295 | if ( !$feature_list ) { |
| 289 | 296 | $feature_list = themes_api( 'feature_list', array() ); |
| 290 | - if ( is_wp_error( $feature_list ) ) |
|
| 291 | - return $features; |
|
| 297 | + if ( is_wp_error( $feature_list ) ) { |
|
| 298 | + return $features; |
|
| 299 | + } |
|
| 292 | 300 | } |
| 293 | 301 | |
| 294 | - if ( !$feature_list ) |
|
| 295 | - return $features; |
|
| 302 | + if ( !$feature_list ) { |
|
| 303 | + return $features; |
|
| 304 | + } |
|
| 296 | 305 | |
| 297 | 306 | set_site_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS ); |
| 298 | 307 | |
@@ -305,15 +314,17 @@ discard block |
||
| 305 | 314 | // Loop over the wporg canonical list and apply translations |
| 306 | 315 | $wporg_features = array(); |
| 307 | 316 | foreach ( (array) $feature_list as $feature_category => $feature_items ) { |
| 308 | - if ( isset($category_translations[$feature_category]) ) |
|
| 309 | - $feature_category = $category_translations[$feature_category]; |
|
| 317 | + if ( isset($category_translations[$feature_category]) ) { |
|
| 318 | + $feature_category = $category_translations[$feature_category]; |
|
| 319 | + } |
|
| 310 | 320 | $wporg_features[$feature_category] = array(); |
| 311 | 321 | |
| 312 | 322 | foreach ( $feature_items as $feature ) { |
| 313 | - if ( isset($features[$feature_category][$feature]) ) |
|
| 314 | - $wporg_features[$feature_category][$feature] = $features[$feature_category][$feature]; |
|
| 315 | - else |
|
| 316 | - $wporg_features[$feature_category][$feature] = $feature; |
|
| 323 | + if ( isset($features[$feature_category][$feature]) ) { |
|
| 324 | + $wporg_features[$feature_category][$feature] = $features[$feature_category][$feature]; |
|
| 325 | + } else { |
|
| 326 | + $wporg_features[$feature_category][$feature] = $feature; |
|
| 327 | + } |
|
| 317 | 328 | } |
| 318 | 329 | } |
| 319 | 330 | |
@@ -447,8 +458,9 @@ discard block |
||
| 447 | 458 | |
| 448 | 459 | if ( ! $res ) { |
| 449 | 460 | $url = $http_url = 'http://api.wordpress.org/themes/info/1.0/'; |
| 450 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
| 451 | - $url = set_url_scheme( $url, 'https' ); |
|
| 461 | + if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { |
|
| 462 | + $url = set_url_scheme( $url, 'https' ); |
|
| 463 | + } |
|
| 452 | 464 | |
| 453 | 465 | $http_args = array( |
| 454 | 466 | 'body' => array( |
@@ -469,8 +481,9 @@ discard block |
||
| 469 | 481 | $res = new WP_Error('themes_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() ); |
| 470 | 482 | } else { |
| 471 | 483 | $res = maybe_unserialize( wp_remote_retrieve_body( $request ) ); |
| 472 | - if ( ! is_object( $res ) && ! is_array( $res ) ) |
|
| 473 | - $res = new WP_Error('themes_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) ); |
|
| 484 | + if ( ! is_object( $res ) && ! is_array( $res ) ) { |
|
| 485 | + $res = new WP_Error('themes_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) ); |
|
| 486 | + } |
|
| 474 | 487 | } |
| 475 | 488 | } |
| 476 | 489 | |
@@ -6,34 +6,34 @@ discard block |
||
| 6 | 6 | * @subpackage Administration |
| 7 | 7 | */ |
| 8 | 8 | /** WordPress Administration Bootstrap */ |
| 9 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
| 9 | +require_once(dirname(__FILE__).'/admin.php'); |
|
| 10 | 10 | |
| 11 | -if ( ! current_user_can( 'manage_options' ) ) |
|
| 12 | - wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) ); |
|
| 11 | +if ( ! current_user_can('manage_options')) |
|
| 12 | + wp_die(__('Sorry, you are not allowed to manage options for this site.')); |
|
| 13 | 13 | |
| 14 | 14 | $title = __('Discussion Settings'); |
| 15 | 15 | $parent_file = 'options-general.php'; |
| 16 | 16 | |
| 17 | -add_action( 'admin_print_footer_scripts', 'options_discussion_add_js' ); |
|
| 17 | +add_action('admin_print_footer_scripts', 'options_discussion_add_js'); |
|
| 18 | 18 | |
| 19 | -get_current_screen()->add_help_tab( array( |
|
| 19 | +get_current_screen()->add_help_tab(array( |
|
| 20 | 20 | 'id' => 'overview', |
| 21 | 21 | 'title' => __('Overview'), |
| 22 | - 'content' => '<p>' . __('This screen provides many options for controlling the management and display of comments and links to your posts/pages. So many, in fact, they won’t all fit here! :) Use the documentation links to get information on what each discussion setting does.') . '</p>' . |
|
| 23 | - '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>', |
|
| 24 | -) ); |
|
| 22 | + 'content' => '<p>'.__('This screen provides many options for controlling the management and display of comments and links to your posts/pages. So many, in fact, they won’t all fit here! :) Use the documentation links to get information on what each discussion setting does.').'</p>'. |
|
| 23 | + '<p>'.__('You must click the Save Changes button at the bottom of the screen for new settings to take effect.').'</p>', |
|
| 24 | +)); |
|
| 25 | 25 | |
| 26 | 26 | get_current_screen()->set_help_sidebar( |
| 27 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
| 28 | - '<p>' . __('<a href="https://codex.wordpress.org/Settings_Discussion_Screen" target="_blank">Documentation on Discussion Settings</a>') . '</p>' . |
|
| 29 | - '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
| 27 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
| 28 | + '<p>'.__('<a href="https://codex.wordpress.org/Settings_Discussion_Screen" target="_blank">Documentation on Discussion Settings</a>').'</p>'. |
|
| 29 | + '<p>'.__('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>').'</p>' |
|
| 30 | 30 | ); |
| 31 | 31 | |
| 32 | -include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
| 32 | +include(ABSPATH.'wp-admin/admin-header.php'); |
|
| 33 | 33 | ?> |
| 34 | 34 | |
| 35 | 35 | <div class="wrap"> |
| 36 | -<h1><?php echo esc_html( $title ); ?></h1> |
|
| 36 | +<h1><?php echo esc_html($title); ?></h1> |
|
| 37 | 37 | |
| 38 | 38 | <form method="post" action="options.php"> |
| 39 | 39 | <?php settings_fields('discussion'); ?> |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | <input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> /> |
| 55 | 55 | <?php _e('Allow people to post comments on new articles'); ?></label> |
| 56 | 56 | <br /> |
| 57 | -<p class="description"><?php echo '(' . __( 'These settings may be overridden for individual articles.' ) . ')'; ?></p> |
|
| 57 | +<p class="description"><?php echo '('.__('These settings may be overridden for individual articles.').')'; ?></p> |
|
| 58 | 58 | </fieldset></td> |
| 59 | 59 | </tr> |
| 60 | 60 | <tr> |
@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | <label for="comment_registration"> |
| 66 | 66 | <input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_option('comment_registration')); ?> /> |
| 67 | 67 | <?php _e('Users must be registered and logged in to comment'); ?> |
| 68 | -<?php if ( !get_option( 'users_can_register' ) && is_multisite() ) echo ' ' . __( '(Signup has been disabled. Only members of this site can comment.)' ); ?> |
|
| 68 | +<?php if ( ! get_option('users_can_register') && is_multisite()) echo ' '.__('(Signup has been disabled. Only members of this site can comment.)'); ?> |
|
| 69 | 69 | </label> |
| 70 | 70 | <br /> |
| 71 | 71 | |
| 72 | 72 | <label for="close_comments_for_old_posts"> |
| 73 | 73 | <input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked('1', get_option('close_comments_for_old_posts')); ?> /> |
| 74 | -<?php printf( __('Automatically close comments on articles older than %s days'), '</label><label for="close_comments_days_old"><input name="close_comments_days_old" type="number" min="0" step="1" id="close_comments_days_old" value="' . esc_attr(get_option('close_comments_days_old')) . '" class="small-text" />'); ?> |
|
| 74 | +<?php printf(__('Automatically close comments on articles older than %s days'), '</label><label for="close_comments_days_old"><input name="close_comments_days_old" type="number" min="0" step="1" id="close_comments_days_old" value="'.esc_attr(get_option('close_comments_days_old')).'" class="small-text" />'); ?> |
|
| 75 | 75 | </label> |
| 76 | 76 | <br /> |
| 77 | 77 | <label for="thread_comments"> |
@@ -84,42 +84,42 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @param int $max_depth The maximum depth of threaded comments. Default 10. |
| 86 | 86 | */ |
| 87 | -$maxdeep = (int) apply_filters( 'thread_comments_depth_max', 10 ); |
|
| 87 | +$maxdeep = (int) apply_filters('thread_comments_depth_max', 10); |
|
| 88 | 88 | |
| 89 | 89 | $thread_comments_depth = '</label><label for="thread_comments_depth"><select name="thread_comments_depth" id="thread_comments_depth">'; |
| 90 | -for ( $i = 2; $i <= $maxdeep; $i++ ) { |
|
| 91 | - $thread_comments_depth .= "<option value='" . esc_attr($i) . "'"; |
|
| 92 | - if ( get_option('thread_comments_depth') == $i ) $thread_comments_depth .= " selected='selected'"; |
|
| 90 | +for ($i = 2; $i <= $maxdeep; $i++) { |
|
| 91 | + $thread_comments_depth .= "<option value='".esc_attr($i)."'"; |
|
| 92 | + if (get_option('thread_comments_depth') == $i) $thread_comments_depth .= " selected='selected'"; |
|
| 93 | 93 | $thread_comments_depth .= ">$i</option>"; |
| 94 | 94 | } |
| 95 | 95 | $thread_comments_depth .= '</select>'; |
| 96 | 96 | |
| 97 | -printf( __('Enable threaded (nested) comments %s levels deep'), $thread_comments_depth ); |
|
| 97 | +printf(__('Enable threaded (nested) comments %s levels deep'), $thread_comments_depth); |
|
| 98 | 98 | |
| 99 | 99 | ?></label> |
| 100 | 100 | <br /> |
| 101 | 101 | <label for="page_comments"> |
| 102 | -<input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked( '1', get_option( 'page_comments' ) ); ?> /> |
|
| 102 | +<input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked('1', get_option('page_comments')); ?> /> |
|
| 103 | 103 | <?php |
| 104 | 104 | $default_comments_page = '</label><label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"'; |
| 105 | -if ( 'newest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"'; |
|
| 106 | -$default_comments_page .= '>' . __('last') . '</option><option value="oldest"'; |
|
| 107 | -if ( 'oldest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"'; |
|
| 108 | -$default_comments_page .= '>' . __('first') . '</option></select>'; |
|
| 105 | +if ('newest' == get_option('default_comments_page')) $default_comments_page .= ' selected="selected"'; |
|
| 106 | +$default_comments_page .= '>'.__('last').'</option><option value="oldest"'; |
|
| 107 | +if ('oldest' == get_option('default_comments_page')) $default_comments_page .= ' selected="selected"'; |
|
| 108 | +$default_comments_page .= '>'.__('first').'</option></select>'; |
|
| 109 | 109 | |
| 110 | -printf( __('Break comments into pages with %1$s top level comments per page and the %2$s page displayed by default'), '</label><label for="comments_per_page"><input name="comments_per_page" type="number" step="1" min="0" id="comments_per_page" value="' . esc_attr(get_option('comments_per_page')) . '" class="small-text" />', $default_comments_page ); |
|
| 110 | +printf(__('Break comments into pages with %1$s top level comments per page and the %2$s page displayed by default'), '</label><label for="comments_per_page"><input name="comments_per_page" type="number" step="1" min="0" id="comments_per_page" value="'.esc_attr(get_option('comments_per_page')).'" class="small-text" />', $default_comments_page); |
|
| 111 | 111 | |
| 112 | 112 | ?></label> |
| 113 | 113 | <br /> |
| 114 | 114 | <label for="comment_order"><?php |
| 115 | 115 | |
| 116 | 116 | $comment_order = '<select name="comment_order" id="comment_order"><option value="asc"'; |
| 117 | -if ( 'asc' == get_option('comment_order') ) $comment_order .= ' selected="selected"'; |
|
| 118 | -$comment_order .= '>' . __('older') . '</option><option value="desc"'; |
|
| 119 | -if ( 'desc' == get_option('comment_order') ) $comment_order .= ' selected="selected"'; |
|
| 120 | -$comment_order .= '>' . __('newer') . '</option></select>'; |
|
| 117 | +if ('asc' == get_option('comment_order')) $comment_order .= ' selected="selected"'; |
|
| 118 | +$comment_order .= '>'.__('older').'</option><option value="desc"'; |
|
| 119 | +if ('desc' == get_option('comment_order')) $comment_order .= ' selected="selected"'; |
|
| 120 | +$comment_order .= '>'.__('newer').'</option></select>'; |
|
| 121 | 121 | |
| 122 | -printf( __('Comments should be displayed with the %s comments at the top of each page'), $comment_order ); |
|
| 122 | +printf(__('Comments should be displayed with the %s comments at the top of each page'), $comment_order); |
|
| 123 | 123 | |
| 124 | 124 | ?></label> |
| 125 | 125 | </fieldset></td> |
@@ -149,11 +149,11 @@ discard block |
||
| 149 | 149 | <tr> |
| 150 | 150 | <th scope="row"><?php _e('Comment Moderation'); ?></th> |
| 151 | 151 | <td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Moderation'); ?></span></legend> |
| 152 | -<p><label for="comment_max_links"><?php printf(__('Hold a comment in the queue if it contains %s or more links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="number" step="1" min="0" id="comment_max_links" value="' . esc_attr(get_option('comment_max_links')) . '" class="small-text" />' ); ?></label></p> |
|
| 152 | +<p><label for="comment_max_links"><?php printf(__('Hold a comment in the queue if it contains %s or more links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="number" step="1" min="0" id="comment_max_links" value="'.esc_attr(get_option('comment_max_links')).'" class="small-text" />'); ?></label></p> |
|
| 153 | 153 | |
| 154 | 154 | <p><label for="moderation_keys"><?php _e('When a comment contains any of these words in its content, name, URL, email, or IP, it will be held in the <a href="edit-comments.php?comment_status=moderated">moderation queue</a>. One word or IP per line. It will match inside words, so “press” will match “WordPress”.'); ?></label></p> |
| 155 | 155 | <p> |
| 156 | -<textarea name="moderation_keys" rows="10" cols="50" id="moderation_keys" class="large-text code"><?php echo esc_textarea( get_option( 'moderation_keys' ) ); ?></textarea> |
|
| 156 | +<textarea name="moderation_keys" rows="10" cols="50" id="moderation_keys" class="large-text code"><?php echo esc_textarea(get_option('moderation_keys')); ?></textarea> |
|
| 157 | 157 | </p> |
| 158 | 158 | </fieldset></td> |
| 159 | 159 | </tr> |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | <td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Blacklist'); ?></span></legend> |
| 163 | 163 | <p><label for="blacklist_keys"><?php _e('When a comment contains any of these words in its content, name, URL, email, or IP, it will be put in the trash. One word or IP per line. It will match inside words, so “press” will match “WordPress”.'); ?></label></p> |
| 164 | 164 | <p> |
| 165 | -<textarea name="blacklist_keys" rows="10" cols="50" id="blacklist_keys" class="large-text code"><?php echo esc_textarea( get_option( 'blacklist_keys' ) ); ?></textarea> |
|
| 165 | +<textarea name="blacklist_keys" rows="10" cols="50" id="blacklist_keys" class="large-text code"><?php echo esc_textarea(get_option('blacklist_keys')); ?></textarea> |
|
| 166 | 166 | </p> |
| 167 | 167 | </fieldset></td> |
| 168 | 168 | </tr> |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | <?php |
| 177 | 177 | // the above would be a good place to link to codex documentation on the gravatar functions, for putting it in themes. anything like that? |
| 178 | 178 | |
| 179 | -$show_avatars = get_option( 'show_avatars' ); |
|
| 179 | +$show_avatars = get_option('show_avatars'); |
|
| 180 | 180 | ?> |
| 181 | 181 | |
| 182 | 182 | <table class="form-table"> |
@@ -184,12 +184,12 @@ discard block |
||
| 184 | 184 | <th scope="row"><?php _e('Avatar Display'); ?></th> |
| 185 | 185 | <td><fieldset><legend class="screen-reader-text"><span><?php _e('Avatar Display'); ?></span></legend> |
| 186 | 186 | <label for="show_avatars"> |
| 187 | - <input type="checkbox" id="show_avatars" name="show_avatars" value="1" <?php checked( $show_avatars, 1 ); ?> /> |
|
| 188 | - <?php _e( 'Show Avatars' ); ?> |
|
| 187 | + <input type="checkbox" id="show_avatars" name="show_avatars" value="1" <?php checked($show_avatars, 1); ?> /> |
|
| 188 | + <?php _e('Show Avatars'); ?> |
|
| 189 | 189 | </label> |
| 190 | 190 | </fieldset></td> |
| 191 | 191 | </tr> |
| 192 | -<tr class="avatar-settings<?php if ( ! $show_avatars ) echo ' hide-if-js'; ?>"> |
|
| 192 | +<tr class="avatar-settings<?php if ( ! $show_avatars) echo ' hide-if-js'; ?>"> |
|
| 193 | 193 | <th scope="row"><?php _e('Maximum Rating'); ?></th> |
| 194 | 194 | <td><fieldset><legend class="screen-reader-text"><span><?php _e('Maximum Rating'); ?></span></legend> |
| 195 | 195 | |
@@ -206,13 +206,13 @@ discard block |
||
| 206 | 206 | ); |
| 207 | 207 | foreach ($ratings as $key => $rating) : |
| 208 | 208 | $selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : ''; |
| 209 | - echo "\n\t<label><input type='radio' name='avatar_rating' value='" . esc_attr($key) . "' $selected/> $rating</label><br />"; |
|
| 209 | + echo "\n\t<label><input type='radio' name='avatar_rating' value='".esc_attr($key)."' $selected/> $rating</label><br />"; |
|
| 210 | 210 | endforeach; |
| 211 | 211 | ?> |
| 212 | 212 | |
| 213 | 213 | </fieldset></td> |
| 214 | 214 | </tr> |
| 215 | -<tr class="avatar-settings<?php if ( ! $show_avatars ) echo ' hide-if-js'; ?>"> |
|
| 215 | +<tr class="avatar-settings<?php if ( ! $show_avatars) echo ' hide-if-js'; ?>"> |
|
| 216 | 216 | <th scope="row"><?php _e('Default Avatar'); ?></th> |
| 217 | 217 | <td class="defaultavatarpicker"><fieldset><legend class="screen-reader-text"><span><?php _e('Default Avatar'); ?></span></legend> |
| 218 | 218 | |
@@ -238,22 +238,22 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @param array $avatar_defaults Array of default avatars. |
| 240 | 240 | */ |
| 241 | -$avatar_defaults = apply_filters( 'avatar_defaults', $avatar_defaults ); |
|
| 242 | -$default = get_option( 'avatar_default', 'mystery' ); |
|
| 241 | +$avatar_defaults = apply_filters('avatar_defaults', $avatar_defaults); |
|
| 242 | +$default = get_option('avatar_default', 'mystery'); |
|
| 243 | 243 | $avatar_list = ''; |
| 244 | 244 | |
| 245 | 245 | // Force avatars on to display these choices |
| 246 | -add_filter( 'pre_option_show_avatars', '__return_true', 100 ); |
|
| 246 | +add_filter('pre_option_show_avatars', '__return_true', 100); |
|
| 247 | 247 | |
| 248 | -foreach ( $avatar_defaults as $default_key => $default_name ) { |
|
| 248 | +foreach ($avatar_defaults as $default_key => $default_name) { |
|
| 249 | 249 | $selected = ($default == $default_key) ? 'checked="checked" ' : ''; |
| 250 | - $avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='" . esc_attr($default_key) . "' {$selected}/> "; |
|
| 251 | - $avatar_list .= get_avatar( $user_email, 32, $default_key, '', array( 'force_default' => true ) ); |
|
| 252 | - $avatar_list .= ' ' . $default_name . '</label>'; |
|
| 250 | + $avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='".esc_attr($default_key)."' {$selected}/> "; |
|
| 251 | + $avatar_list .= get_avatar($user_email, 32, $default_key, '', array('force_default' => true)); |
|
| 252 | + $avatar_list .= ' '.$default_name.'</label>'; |
|
| 253 | 253 | $avatar_list .= '<br />'; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | -remove_filter( 'pre_option_show_avatars', '__return_true', 100 ); |
|
| 256 | +remove_filter('pre_option_show_avatars', '__return_true', 100); |
|
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | 259 | * Filters the HTML output of the default avatar list. |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * |
| 263 | 263 | * @param string $avatar_list HTML markup of the avatar list. |
| 264 | 264 | */ |
| 265 | -echo apply_filters( 'default_avatar_select', $avatar_list ); |
|
| 265 | +echo apply_filters('default_avatar_select', $avatar_list); |
|
| 266 | 266 | ?> |
| 267 | 267 | |
| 268 | 268 | </fieldset></td> |
@@ -276,4 +276,4 @@ discard block |
||
| 276 | 276 | </form> |
| 277 | 277 | </div> |
| 278 | 278 | |
| 279 | -<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?> |
|
| 279 | +<?php include(ABSPATH.'wp-admin/admin-footer.php'); ?> |
|