diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index 577a7b18..de882343 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -7,6 +7,7 @@ /vendor/* /node_modules/* + /lang/* @@ -15,7 +16,19 @@ - + + + + + + + + + + + + + diff --git a/acf.php b/acf.php index a3cafdbc..53dcfd52 100644 --- a/acf.php +++ b/acf.php @@ -3,9 +3,11 @@ * This file is for the converting of sites from acf.php to secure-custom-fields.php as the main plugin file. * * Under this slug, acf.php would have been the main plugin file in < 6.4.0-beta4. + * + * @package wordpress/secure-custom-fields */ -// Exit if accessed directly +// Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } diff --git a/includes/acf-field-group-functions.php b/includes/acf-field-group-functions.php index 830de2d2..2f48d8d9 100644 --- a/includes/acf-field-group-functions.php +++ b/includes/acf-field-group-functions.php @@ -126,7 +126,6 @@ function acf_get_field_groups( $filter = array() ) { * @date 18/1/19 * @since 5.7.10 * - * @param void * @return array */ function acf_get_raw_field_groups() { diff --git a/includes/acf-form-functions.php b/includes/acf-form-functions.php index c6605300..25e89368 100644 --- a/includes/acf-form-functions.php +++ b/includes/acf-form-functions.php @@ -42,7 +42,6 @@ function acf_get_form_data( $name = '' ) { * @date 15/10/13 * @since 5.0.0 * - * @param void * @return void */ function acf_form_data( $data = array() ) { diff --git a/includes/acf-helper-functions.php b/includes/acf-helper-functions.php index f79e1c2d..47b8f592 100644 --- a/includes/acf-helper-functions.php +++ b/includes/acf-helper-functions.php @@ -186,7 +186,6 @@ function acf_is_filter_enabled( $name = '' ) { * @date 14/7/16 * @since 5.4.0 * - * @param void * @return array */ function acf_get_filters() { @@ -216,7 +215,6 @@ function acf_set_filters( $filters = array() ) { * @date 14/7/16 * @since 5.4.0 * - * @param void * @return array */ function acf_disable_filters() { @@ -481,7 +479,6 @@ function acf_doing_action( $action ) { * @date 23/01/2015 * @since 5.1.5 * - * @param void * @return string */ function acf_get_current_url() { diff --git a/includes/acf-post-functions.php b/includes/acf-post-functions.php index c583bcd6..af8f2ea6 100644 --- a/includes/acf-post-functions.php +++ b/includes/acf-post-functions.php @@ -6,7 +6,6 @@ * @date 29/8/17 * @since 5.6.2 * - * @param void * @return array */ function acf_get_post_templates() { diff --git a/includes/acf-user-functions.php b/includes/acf-user-functions.php index 6d159f7b..fdf9f9f1 100644 --- a/includes/acf-user-functions.php +++ b/includes/acf-user-functions.php @@ -99,7 +99,6 @@ function acf_get_user_role_labels( $roles = array() ) { * @date 9/1/19 * @since 5.7.10 * - * @param void * @return boolean */ function acf_allow_unfiltered_html() { diff --git a/includes/admin/admin-internal-post-type-list.php b/includes/admin/admin-internal-post-type-list.php index b913c8b9..6d50fc5f 100644 --- a/includes/admin/admin-internal-post-type-list.php +++ b/includes/admin/admin-internal-post-type-list.php @@ -1,5 +1,4 @@ post_type}", array( $this, 'admin_table_bulk_actions' ), 10, 1 ); add_action( 'admin_footer', array( $this, 'admin_footer' ), 1 ); - if ( $this->view !== 'trash' ) { + if ( 'trash' !== $this->view ) { add_filter( 'page_row_actions', array( $this, 'page_row_actions' ), 10, 2 ); } // Add hooks for "sync" view. - if ( $this->view === 'sync' ) { + if ( 'sync' === $this->view ) { add_action( 'admin_footer', array( $this, 'admin_footer__sync' ), 1 ); } @@ -185,7 +189,7 @@ public function setup_sync() { continue; // Ignore not local "json". - } elseif ( $local !== 'json' ) { + } elseif ( 'json' === $local ) { continue; // Append to sync if not yet in database. @@ -271,7 +275,7 @@ public function get_registration_error_state() { * @return array */ public function display_post_states( $post_states, $post ) { - if ( $post->post_status === 'acf-disabled' ) { + if ( 'acf-disabled' === $post->post_status ) { $post_states['acf-disabled'] = $this->get_disabled_post_state(); } @@ -483,7 +487,7 @@ public function admin_table_bulk_actions( $actions ) { } if ( $this->sync ) { - if ( $this->view === 'sync' ) { + if ( 'sync' === $this->view ) { $actions = array(); } $actions['acfsync'] = __( 'Sync changes', 'secure-custom-fields' ); @@ -501,7 +505,7 @@ public function admin_table_bulk_actions( $actions ) { * @param integer $count The number of items the action was performed on. * @return string */ - public function get_action_notice_text( $action, $count = 1 ) { + public function get_action_notice_text( $action, $count = 1 ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed -- Keep it for awareness when extending. return ''; } @@ -773,19 +777,12 @@ public function check_sync() { $synced = array(); foreach ( $this->sync as $key => $post ) { - if ( $post['key'] && in_array( $post['key'], $keys ) ) { - // Import. - } elseif ( $post['ID'] && in_array( $post['ID'], $keys ) ) { - // Import. - } else { - // Ignore. - continue; + if ( ( $post['key'] && in_array( $post['key'], $keys, true ) ) || ( $post['ID'] && in_array( $post['ID'], $keys, true ) ) ) { + $local_post = json_decode( file_get_contents( $files[ $key ] ), true ); + $local_post['ID'] = $post['ID']; + $result = acf_import_internal_post_type( $local_post, $this->post_type ); + $synced[] = $result['ID']; } - - $local_post = json_decode( file_get_contents( $files[ $key ] ), true ); - $local_post['ID'] = $post['ID']; - $result = acf_import_internal_post_type( $local_post, $this->post_type ); - $synced[] = $result['ID']; } // Redirect. @@ -813,7 +810,7 @@ public function admin_table_views( $views ) { if ( $count ) { $views['sync'] = sprintf( '%s (%s)', - ( $this->view === 'sync' ? 'class="current"' : '' ), + ( 'sync' === $this->view ? 'class="current"' : '' ), esc_url( $this->get_admin_url( '&post_status=sync' ) ), esc_html( __( 'Sync available', 'secure-custom-fields' ) ), $count @@ -821,7 +818,7 @@ public function admin_table_views( $views ) { } // Modify table pagination args to match JSON data. - if ( $this->view === 'sync' ) { + if ( 'sync' === $this->view ) { $wp_list_table->set_pagination_args( array( 'total_items' => $count, @@ -903,11 +900,11 @@ public function admin_footer__sync() { echo ''; foreach ( $columns as $column_name => $column_label ) { $el = 'td'; - if ( $column_name === 'cb' ) { + if ( 'cb' === $column_name ) { $el = 'th'; $classes = 'check-column'; $column_label = ''; - } elseif ( $column_name === 'title' ) { + } elseif ( 'title' === $column_name ) { $classes = "$column_name column-$column_name column-primary"; } else { $classes = "$column_name column-$column_name"; diff --git a/includes/admin/admin-internal-post-type.php b/includes/admin/admin-internal-post-type.php index 6901cc78..2e263221 100644 --- a/includes/admin/admin-internal-post-type.php +++ b/includes/admin/admin-internal-post-type.php @@ -164,7 +164,7 @@ public function admin_footer() { * @since 5.3.8 * * @param array $l10n The array of translated strings. - * @return array $l10n + * @return void */ public function admin_l10n( $l10n ) { // Override as necessary. diff --git a/includes/admin/admin-notices.php b/includes/admin/admin-notices.php index 86757951..6ef3f9da 100644 --- a/includes/admin/admin-notices.php +++ b/includes/admin/admin-notices.php @@ -1,4 +1,4 @@ - '', - /** @type string The type of notice (warning, error, success, info). */ + /** The type of notice (warning, error, success, info). @type string */ 'type' => 'info', - /** @type bool If the notice can be dismissed. */ + /** If the notice can be dismissed. @type bool */ 'dismissible' => true, - /** @type bool If the dismissed state should be persisted to ACF user preferences. */ + /** If the dismissed state should be persisted to ACF user preferences. @type bool */ 'persisted' => false, ); /** - * render - * * Renders the notice HTML. * * @date 27/12/18 * @since 5.8.0 * - * @param void * @return void */ - function render() { + public function render() { $notice_text = $this->get( 'text' ); $notice_type = $this->get( 'type' ); $is_dismissible = $this->get( 'dismissible' ); @@ -75,8 +78,6 @@ function render() { endif; // class_exists check /** - * acf_new_admin_notice - * * Instantiates and returns a new model. * * @date 23/12/18 @@ -98,14 +99,11 @@ function acf_new_admin_notice( $data = false ) { } /** - * acf_render_admin_notices - * * Renders all admin notices HTML. * * @date 10/1/19 * @since 5.7.10 * - * @param void * @return void */ function acf_render_admin_notices() { @@ -125,17 +123,15 @@ function acf_render_admin_notices() { add_action( 'admin_notices', 'acf_render_admin_notices', 99 ); /** - * acf_add_admin_notice - * * Creates and returns a new notice. * * @date 17/10/13 * @since 5.0.0 * * @param string $text The admin notice text. - * @param string $class The type of notice (warning, error, success, info). - * @param boolean $dismissable Is this notification dismissible (default true) (since 5.11.0) - * @param boolean $persisted Store once a notice has been dismissed per user and prevent showing it again. (since 6.1.0) + * @param string $type The type of notice (warning, error, success, info). + * @param boolean $dismissible Is this notification dismissible (default true) (since 5.11.0). + * @param boolean $persisted Store once a notice has been dismissed per user and prevent showing it again. (since 6.1.0). * @return ACF_Admin_Notice */ function acf_add_admin_notice( $text = '', $type = 'info', $dismissible = true, $persisted = false ) { diff --git a/includes/admin/admin-tools.php b/includes/admin/admin-tools.php index a78643dd..46a41bf4 100644 --- a/includes/admin/admin-tools.php +++ b/includes/admin/admin-tools.php @@ -1,51 +1,58 @@ -tools[ $instance->name ] = $instance; @@ -53,50 +60,44 @@ function register_tool( $class ) { /** - * get_tool - * - * This function will return a tool tool class + * This function will return a tool class or null if not found. * * @date 10/10/17 * @since 5.6.3 * - * @param string $name - * @return n/a + * @param string $name Name of tool. + * @return mixed (ACF_Admin_Tool|null) */ - function get_tool( $name ) { + public function get_tool( $name ) { return isset( $this->tools[ $name ] ) ? $this->tools[ $name ] : null; } /** - * get_tools - * - * This function will return an array of all tools + * This function will return an array of all tool instances. * * @date 10/10/17 * @since 5.6.3 * - * @param n/a * @return array */ - function get_tools() { + public function get_tools() { return $this->tools; } /** - * This function will add the ACF menu item to the WP admin + * This function will add the SCF menu item to the WP admin * * @type action (admin_menu) * @date 28/09/13 * @since 5.0.0 * - * @param n/a - * @return n/a + * @return void */ - function admin_menu() { + public function admin_menu() { // bail early if no show_admin if ( ! acf_get_setting( 'show_admin' ) ) { @@ -112,17 +113,14 @@ function admin_menu() { /** - * load - * - * description + * Loads the admin tools page. * * @date 10/10/17 * @since 5.6.3 * - * @param n/a - * @return n/a + * @return void */ - function load() { + public function load() { add_action( 'admin_body_class', array( $this, 'admin_body_class' ) ); @@ -153,17 +151,14 @@ public function admin_body_class( $classes ) { } /** - * include_tools - * - * description + * Includes various tool-related files. * * @date 10/10/17 * @since 5.6.3 * - * @param n/a - * @return n/a + * @return void */ - function include_tools() { + public function include_tools() { // include acf_include( 'includes/admin/tools/class-acf-admin-tool.php' ); @@ -176,17 +171,14 @@ function include_tools() { /** - * check_submit - * - * description + * Verifies the nonces and submits the value if it passes. * * @date 10/10/17 * @since 5.6.3 * - * @param n/a - * @return n/a + * @return void */ - function check_submit() { + public function check_submit() { // loop foreach ( $this->get_tools() as $tool ) { @@ -203,17 +195,14 @@ function check_submit() { /** - * html - * - * description + * Admin Tools html * * @date 10/10/17 * @since 5.6.3 * - * @param n/a - * @return n/a + * @return void */ - function html() { + public function html() { // vars $screen = get_current_screen(); @@ -254,7 +243,7 @@ public function metabox_html( $post, $metabox ) { $tool = $this->get_tool( $metabox['args']['tool'] ); $form_attrs = array( 'method' => 'post' ); - if ( $metabox['args']['tool'] === 'import' ) { + if ( 'import' === $metabox['args']['tool'] ) { $form_attrs['onsubmit'] = 'acf.disableForm(event)'; } @@ -271,30 +260,29 @@ public function metabox_html( $post, $metabox ) { /** - * alias of acf()->admin_tools->register_tool() + * Alias of acf()->admin_tools->register_tool() * * @type function * @date 31/5/17 * @since 5.6.0 * - * @param n/a - * @return n/a + * @param ACF_Admin_Tool $class The tool class. + * @return void */ -function acf_register_admin_tool( $class ) { - - return acf()->admin_tools->register_tool( $class ); +function acf_register_admin_tool( $class ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.classFound + acf()->admin_tools->register_tool( $class ); } /** + * * This function will return the admin URL to the tools page * * @type function * @date 31/5/17 * @since 5.6.0 * - * @param n/a - * @return n/a + * @return string The URL to the tools page. */ function acf_get_admin_tools_url() { @@ -309,8 +297,8 @@ function acf_get_admin_tools_url() { * @date 31/5/17 * @since 5.6.0 * - * @param n/a - * @return n/a + * @param string $tool The tool name. + * @return string The URL to a particular tool's page. */ function acf_get_admin_tool_url( $tool = '' ) { diff --git a/includes/admin/admin-upgrade.php b/includes/admin/admin-upgrade.php index aec1ba1c..45e8bf95 100644 --- a/includes/admin/admin-upgrade.php +++ b/includes/admin/admin-upgrade.php @@ -1,11 +1,23 @@ network_upgrade_needed_transient = 'acf_network_upgrade_needed_' . ACF_UPGRADE_VERSION; @@ -37,17 +48,16 @@ function __construct() { } /** - * admin_menu + * Function admin_menu * * Setus up logic if DB Upgrade is needed on a single site. * * @date 24/8/18 * @since 5.7.4 * - * @param void * @return void */ - function admin_menu() { + public function admin_menu() { // check if upgrade is avaialble if ( acf_has_upgrade() ) { @@ -71,15 +81,15 @@ function admin_menu() { * @since 5.7.4 * @since 6.0.0 Reduce memory usage, cache network upgrade checks. */ - function network_admin_menu() { + public function network_admin_menu() { $network_upgrade_needed = get_site_transient( $this->network_upgrade_needed_transient ); // No transient value exists, so run the upgrade check. - if ( $network_upgrade_needed === false ) { + if ( false === $network_upgrade_needed ) { $network_upgrade_needed = $this->check_for_network_upgrades(); } - if ( $network_upgrade_needed === 'no' ) { + if ( 'no' === $network_upgrade_needed ) { return; } @@ -153,17 +163,16 @@ public function check_for_network_upgrades() { } /** - * admin_load + * Function admin_load * * Runs during the loading of the admin page. * * @date 24/8/18 * @since 5.7.4 * - * @param type $var Description. Default. - * @return type Description. + * @return void */ - function admin_load() { + public function admin_load() { add_action( 'admin_body_class', array( $this, 'admin_body_class' ) ); @@ -175,17 +184,16 @@ function admin_load() { } /** - * network_admin_load + * Function network_admin_load * * Runs during the loading of the network admin page. * * @date 24/8/18 * @since 5.7.4 * - * @param type $var Description. Default. - * @return type Description. + * @return void */ - function network_admin_load() { + public function network_admin_load() { add_action( 'admin_body_class', array( $this, 'admin_body_class' ) ); @@ -210,17 +218,16 @@ public function admin_body_class( $classes ) { } /** - * admin_notices + * Function admin_notices * * Displays the DB Upgrade prompt. * * @date 23/8/18 * @since 5.7.3 * - * @param void * @return void */ - function admin_notices() { + public function admin_notices() { // vars $view = array( @@ -234,17 +241,16 @@ function admin_notices() { } /** - * network_admin_notices + * Function network_admin_notices * * Displays the DB Upgrade prompt on a multi site. * * @date 23/8/18 * @since 5.7.3 * - * @param void * @return void */ - function network_admin_notices() { + public function network_admin_notices() { // vars $view = array( @@ -258,32 +264,30 @@ function network_admin_notices() { } /** - * admin_html + * Function admin_html * * Displays the HTML for the admin page. * * @date 24/8/18 * @since 5.7.4 * - * @param void * @return void */ - function admin_html() { + public function admin_html() { acf_get_view( 'upgrade/upgrade' ); } /** - * network_admin_html + * Function network_admin_html * * Displays the HTML for the network upgrade admin page. * * @date 24/8/18 * @since 5.7.4 * - * @param void * @return void */ - function network_admin_html() { + public function network_admin_html() { acf_get_view( 'upgrade/network' ); } } diff --git a/includes/admin/admin.php b/includes/admin/admin.php index 84797279..7488ab1e 100644 --- a/includes/admin/admin.php +++ b/includes/admin/admin.php @@ -99,7 +99,6 @@ public function admin_body_class( $classes ) { * @date 7/4/20 * @since 5.9.0 * - * @param void * @return void */ public function current_screen( $screen ) { @@ -226,7 +225,6 @@ public function clear_escaped_html_log() { * @date 27/3/20 * @since 5.9.0 * - * @param void * @return void */ function in_admin_header() { diff --git a/includes/admin/index.php b/includes/admin/index.php index 97611c0c..bc4aa091 100644 --- a/includes/admin/index.php +++ b/includes/admin/index.php @@ -1,2 +1,2 @@ -errors = array(); @@ -39,11 +38,10 @@ function __construct() { * @date 25/11/2013 * @since 5.0.0 * - * @param $input (string) name attribute of DOM elmenet - * @param $message (string) error message - * @return $post_id (int) + * @param string $input name attribute of DOM elmenet. + * @param string $message error message. */ - function add_error( $input, $message ) { + public function add_error( $input, $message ) { // add to array $this->errors[] = array( @@ -60,10 +58,10 @@ function add_error( $input, $message ) { * @date 5/03/2016 * @since 5.3.2 * - * @param $input (string) name attribute of DOM elmenet - * @return (mixed) + * @param string $input name attribute of DOM elmenet. + * @return array|bool */ - function get_error( $input ) { + public function get_error( $input ) { // bail early if no errors if ( empty( $this->errors ) ) { @@ -89,10 +87,9 @@ function get_error( $input ) { * @date 25/11/2013 * @since 5.0.0 * - * @param n/a - * @return (array|boolean) + * @return array|bool */ - function get_errors() { + public function get_errors() { // bail early if no errors if ( empty( $this->errors ) ) { @@ -111,10 +108,9 @@ function get_errors() { * @date 4/03/2016 * @since 5.3.2 * - * @param n/a - * @return n/a + * @return void */ - function reset_errors() { + public function reset_errors() { $this->errors = array(); } @@ -176,7 +172,7 @@ public function acf_validate_save_post() { return; } - acf_validate_values( $_POST['acf'], 'acf' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized + acf_validate_values( wp_unslash( $_POST['acf'] ), 'acf' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized } // phpcs:enable WordPress.Security.NonceVerification.Missing } @@ -188,35 +184,68 @@ public function acf_validate_save_post() { /** - * Public functions + * Add validation error. * - * alias of acf()->validation->function() + * Alias of acf()->validation->add_error() * * @type function * @date 6/10/13 * @since 5.0.0 * - * @param n/a - * @return n/a + * @param string $input name attribute of DOM elmenet. + * @param string $message error message. + * @return void */ function acf_add_validation_error( $input, $message = '' ) { - - return acf()->validation->add_error( $input, $message ); + acf()->validation->add_error( $input, $message ); } +/** + * Retrieve validation errors. + * + * Alias of acf()->validation->function() + * + * @type function + * @date 6/10/13 + * @since 5.0.0 + * + * @return array|bool + */ function acf_get_validation_errors() { - return acf()->validation->get_errors(); } -function acf_get_validation_error() { - +/** + * Get the validation error. + * + * Alias of acf()->validation->get_error() + * + * @type function + * @date 6/10/13 + * @since 5.0.0 + * @since 6.4.1 Added the $input parameter, which is required in the get_error method. + * + * @param string $input name attribute of DOM elmenet. + * + * @return string|bool + */ +function acf_get_validation_error( $input ) { return acf()->validation->get_error( $input ); } +/** + * Reset Validation errors. + * + * Alias of acf()->validation->reset_errors() + * + * @type function + * @date 6/10/13 + * @since 5.0.0 + * + * @return void + */ function acf_reset_validation_errors() { - - return acf()->validation->reset_errors(); + acf()->validation->reset_errors(); } @@ -227,8 +256,8 @@ function acf_reset_validation_errors() { * @date 25/11/2013 * @since 5.0.0 * - * @param $show_errors (boolean) if true, errors will be shown via a wp_die screen - * @return (boolean) + * @param bool $show_errors if true, errors will be shown via a wp_die screen. + * @return bool */ function acf_validate_save_post( $show_errors = false ) { @@ -268,9 +297,10 @@ function acf_validate_save_post( $show_errors = false ) { * @date 6/10/13 * @since 5.0.0 * - * @param values (array) - * @param $input_prefix (string) - * @return n/a + * @param array $values An array of field values. + * @param string $input_prefix The input element's name attribute. + * + * @return void */ function acf_validate_values( $values, $input_prefix = '' ) { @@ -304,8 +334,11 @@ function acf_validate_values( $values, $input_prefix = '' ) { * @date 6/10/13 * @since 5.0.0 * - * @param n/a - * @return n/a + * @param mixed $value The field value to validate. + * @param array $field The field array. + * @param string $input The input element's name attribute. + * + * @return boolean */ function acf_validate_value( $value, $field, $input ) { diff --git a/includes/wpml.php b/includes/wpml.php index b1f0e95e..8bd25faa 100644 --- a/includes/wpml.php +++ b/includes/wpml.php @@ -1,4 +1,9 @@ $path ) { $paths[ $i ] = untrailingslashit( $path ) . '/' . acf_get_setting( 'current_language' ); } @@ -235,20 +236,22 @@ function settings_load_json( $paths ) { } /** - * icl_make_duplicate - * - * description + * Duplicate the icl_translations row when duplicating a field group. * * @date 26/02/2014 * @since 5.0.0 * - * @param void + * @param int $master_post_id The original post ID. + * @param string $lang The language code. + * @param array $postarr The post data. + * @param int $id The new post ID. + * * @return void */ - function icl_make_duplicate( $master_post_id, $lang, $postarr, $id ) { + public function icl_make_duplicate( $master_post_id, $lang, $postarr, $id ) { // bail early if not acf-field-group - if ( $postarr['post_type'] != 'acf-field-group' ) { + if ( 'acf-field-group' !== $postarr['post_type'] ) { return; } @@ -261,38 +264,35 @@ function icl_make_duplicate( $master_post_id, $lang, $postarr, $id ) { // always translate independately to avoid many many bugs! // - translation post gets a new key (post_name) when origional post is saved // - local json creates new files due to changed key + // phpcs:disable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase -- Variable name is from WPML. global $iclTranslationManagement; $iclTranslationManagement->reset_duplicate_flag( $id ); + // phpcs:enable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase } /** - * verify_ajax - * * Sets the correct language during AJAX requests. * * @type function * @date 7/08/2015 * @since 5.2.3 * - * @param void * @return void */ - function verify_ajax() { + public function verify_ajax() { // phpcs:disable WordPress.Security.NonceVerification.Recommended -- Verified elsewhere. // set the language for this AJAX request // this will allow get_posts to work as expected (load posts from the correct language) if ( isset( $_REQUEST['lang'] ) ) { global $sitepress; - $sitepress->switch_lang( sanitize_text_field( $_REQUEST['lang'] ) ); + $sitepress->switch_lang( sanitize_text_field( wp_unslash( $_REQUEST['lang'] ) ) ); } // phpcs:enable WordPress.Security.NonceVerification.Recommended } /** - * get_translatable_documents - * * Removes 'acf-field' from the available post types for translation. * * @type function @@ -302,7 +302,7 @@ function verify_ajax() { * @param array $icl_post_types The array of post types. * @return array */ - function get_translatable_documents( $icl_post_types ) { + public function get_translatable_documents( $icl_post_types ) { // unset unset( $icl_post_types['acf-field'] ); diff --git a/index.php b/index.php index 226f970f..a004ea20 100644 --- a/index.php +++ b/index.php @@ -1,2 +1,2 @@ -=' ) ) { $this->settings['enable_shortcode'] = false; } @@ -640,7 +642,7 @@ public function set_data( $name, $value ) { * @param string $class The instance class name. * @return object */ - public function get_instance( $class ) { + public function get_instance( $class ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.classFound -- Opting not to rename due to PHP 8.0 named arugments. $name = strtolower( $class ); return isset( $this->instances[ $name ] ) ? $this->instances[ $name ] : null; } @@ -654,7 +656,7 @@ public function get_instance( $class ) { * @param string $class The instance class name. * @return object */ - public function new_instance( $class ) { + public function new_instance( $class ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.classFound -- Opting not to rename due to PHP 8.0 named arugments. $instance = new $class(); $name = strtolower( $class ); $this->instances[ $name ] = $instance; @@ -741,25 +743,23 @@ function acf() { /** * Checks if another version of ACF/ACF PRO is active and deactivates it. * Hooked on `activated_plugin` so other plugin is deactivated when current plugin is activated. - * - * @param string $plugin The plugin being activated. */ - function scf_deactivate_other_instances( $plugin ) { + function scf_deactivate_other_instances() { $plugin_to_deactivate = 'advanced-custom-fields/acf.php'; $deactivated_notice_id = '1'; - // Check if the plugin to deactivate is installed + // Check if the plugin to deactivate is installed. if ( is_plugin_active( 'advanced-custom-fields-pro/acf.php' ) ) { $plugin_to_deactivate = 'advanced-custom-fields-pro/acf.php'; $deactivated_notice_id = '2'; } elseif ( is_plugin_active( 'advanced-custom-fields/acf.php' ) ) { - // Check if the plugin to deactivate is 'advanced-custom-fields/acf.php' but the title is 'Secure Custom Fields' + // Check if the plugin to deactivate is 'advanced-custom-fields/acf.php' but the title is 'Secure Custom Fields'. if ( ! function_exists( 'get_plugin_data' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_to_deactivate ); - if ( $plugin_data['Name'] === 'Secure Custom Fields' ) { + if ( 'Secure Custom Fields' === $plugin_data['Name'] ) { $deactivated_notice_id = '3'; } }