__( 'Select Image', 'wpsso' ),
);
}
public function admin_register_page_scripts( $hook_name ) {
if ( $this->p->debug->enabled ) {
$this->p->debug->log( 'registering script sucom-admin-page' );
}
$admin_l10n = $this->p->cf[ 'plugin' ][ 'wpsso' ][ 'admin_l10n' ];
/*
* The version number should match the version in js/com/jquery-admin-page.js.
*/
wp_register_script( 'sucom-admin-page', WPSSO_URLPATH . 'js/com/jquery-admin-page.' . $this->file_ext,
$deps = array( 'jquery' ), '20240810', $in_footer = true );
wp_localize_script( 'sucom-admin-page', $admin_l10n, $this->get_admin_page_script_data() );
}
/*
* This method is run a second time by the 'admin_enqueue_scripts' action with a priority of PHP_INT_MAX to make
* sure another plugin (like Squirrly SEO) has not cleared our admin page scripts from the queue.
*/
public function admin_enqueue_page_scripts( $hook_name ) {
$script_handles = array( 'sucom-admin-page', 'jquery' );
static $is_enqueued = null; // Default value for first execution.
if ( ! $is_enqueued ) { // Re-check the $wp_scripts queue at priority PHP_INT_MAX.
add_action( 'admin_enqueue_scripts', array( $this, __FUNCTION__ ), PHP_INT_MAX );
}
global $wp_scripts;
foreach ( $script_handles as $handle ) {
if ( ! $is_enqueued || ! isset( $wp_scripts->queue ) || ! in_array( $handle, $wp_scripts->queue ) ) {
if ( $this->p->debug->enabled ) {
$this->p->debug->log( 'enqueueing script ' . $handle );
}
wp_enqueue_script( $handle );
} elseif ( $this->p->debug->enabled ) {
$this->p->debug->log( $handle . ' script already enqueued' );
}
}
$is_enqueued = true; // Signal that we've already run once.
}
/*
* The config array for the 'sucom-admin-page' script located in js/com/jquery-admin-page.js.
*/
public function get_admin_page_script_data() {
$admin_l10n = $this->p->cf[ 'plugin' ][ 'wpsso' ][ 'admin_l10n' ];
$option_labels = apply_filters( 'wpsso_admin_page_script_data_option_labels', array(
'schema_type' => _x( 'Schema Type', 'option label', 'wpsso' ),
) );
/*
* noticeTime = -1 to skip automatically showing notifications.
* noticeTime = 0 to automatically show notifications until click or hover.
* noticeTime = milliseconds to automatically show notifications.
*/
$toolbar_notice_timeout = array(
'err' => WPSSO_TB_NOTICE_TIME_ERR,
'warn' => WPSSO_TB_NOTICE_TIME_WARN,
'inf' => WPSSO_TB_NOTICE_TIME_INF,
'upd' => WPSSO_TB_NOTICE_TIME_UPD,
);
$toolbar_notice_types = $this->p->notice->get_toolbar_types();
$notice_text_uniqid = 'wpsso_' . uniqid(); // CSS id of hidden notice text container.
$no_notices_transl = sprintf( __( 'No %s notifications.', 'wpsso' ), $this->p->cf[ 'menu' ][ 'title' ] );
$no_notices_html = '' . $no_notices_transl . '
';
$copy_notices_transl = __( 'Copy notifications to clipboard.', 'wpsso' );
/*
* Add an 'inline' class to toolbar notices to prevent WordPress from moving the notice.
*
* See wordpress/wp-admin/js/common.js:1083
*/
$copy_notices_html = '';
/*
* The config array.
*/
$metabox_id = $this->p->cf[ 'meta' ][ 'id' ];
return array(
'_ajax_nonce' => wp_create_nonce( WPSSO_NONCE_NAME ),
'_ajax_actions' => array(
'schema_type_og_type' => 'wpsso_schema_type_og_type',
'get_notices_json' => 'wpsso_get_notices_json',
'get_validate_submenu' => 'wpsso_get_validate_submenu',
'metabox_postboxes' => array(
'wpsso_' . $metabox_id => 'wpsso_get_metabox_postbox_id_' . $metabox_id . '_inside',
),
),
'_option_labels' => $option_labels,
'_toolbar_notice_timeout' => $toolbar_notice_timeout,
'_toolbar_notice_types' => $toolbar_notice_types, // Maybe null, true, false, or array.
'_notice_text_id' => $notice_text_uniqid, // CSS id of hidden notice text container.
'_no_notices_html' => $no_notices_html,
'_copy_notices_html' => $copy_notices_html,
'_copy_clipboard_transl' => __( 'Copied to clipboard.', 'wpsso' ),
'_linked_to_transl' => __( 'Value linked to {0} option', 'wpsso' ),
'_count_msgs_transl' => array(
'error' => sprintf( __( 'There are {0} important error messages under the %s notification icon.', 'wpsso' ),
$this->p->cf[ 'notice' ][ 'title' ] ),
),
'_min_len_transl' => __( '{0} of {1} characters minimum', 'wpsso' ),
'_req_len_transl' => __( '{0} of {1} characters recommended', 'wpsso' ),
'_max_len_transl' => __( '{0} of {1} characters maximum', 'wpsso' ),
'_len_transl' => __( '{0} characters', 'wpsso' ),
);
}
}
}