v1.2.0
This commit is contained in:
parent
ddaaff71ad
commit
3bb9ed33e1
12 changed files with 1762 additions and 409 deletions
|
|
@ -223,6 +223,126 @@ class Robotstxt_OG_Admin_Settings {
|
|||
)
|
||||
);
|
||||
|
||||
register_setting(
|
||||
'robotstxt_og_settings',
|
||||
'robotstxt_og_fb_app_id',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => '',
|
||||
)
|
||||
);
|
||||
|
||||
register_setting(
|
||||
'robotstxt_og_settings',
|
||||
'robotstxt_og_fb_admins',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => '',
|
||||
)
|
||||
);
|
||||
|
||||
register_setting(
|
||||
'robotstxt_og_settings',
|
||||
'robotstxt_og_fb_pages',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => '',
|
||||
)
|
||||
);
|
||||
|
||||
register_setting(
|
||||
'robotstxt_og_settings',
|
||||
'robotstxt_og_pinterest_verify',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => '',
|
||||
)
|
||||
);
|
||||
|
||||
register_setting(
|
||||
'robotstxt_og_settings',
|
||||
'robotstxt_og_pinterest_nopin',
|
||||
array(
|
||||
'type' => 'boolean',
|
||||
'sanitize_callback' => 'rest_sanitize_boolean',
|
||||
'default' => false,
|
||||
)
|
||||
);
|
||||
|
||||
register_setting(
|
||||
'robotstxt_og_settings',
|
||||
'robotstxt_og_telegram_channel',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => '',
|
||||
)
|
||||
);
|
||||
|
||||
register_setting(
|
||||
'robotstxt_og_settings',
|
||||
'robotstxt_og_slack_app_id',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => '',
|
||||
)
|
||||
);
|
||||
|
||||
register_setting(
|
||||
'robotstxt_og_settings',
|
||||
'robotstxt_og_theme_color',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_hex_color',
|
||||
'default' => '',
|
||||
)
|
||||
);
|
||||
|
||||
register_setting(
|
||||
'robotstxt_og_settings',
|
||||
'robotstxt_og_app_name',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => '',
|
||||
)
|
||||
);
|
||||
|
||||
register_setting(
|
||||
'robotstxt_og_settings',
|
||||
'robotstxt_og_web_app_capable',
|
||||
array(
|
||||
'type' => 'boolean',
|
||||
'sanitize_callback' => 'rest_sanitize_boolean',
|
||||
'default' => false,
|
||||
)
|
||||
);
|
||||
|
||||
register_setting(
|
||||
'robotstxt_og_settings',
|
||||
'robotstxt_og_app_status_bar_style',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => array( $this, 'sanitize_status_bar_style' ),
|
||||
'default' => '',
|
||||
)
|
||||
);
|
||||
|
||||
register_setting(
|
||||
'robotstxt_og_settings',
|
||||
'robotstxt_og_format_detection',
|
||||
array(
|
||||
'type' => 'boolean',
|
||||
'sanitize_callback' => 'rest_sanitize_boolean',
|
||||
'default' => false,
|
||||
)
|
||||
);
|
||||
|
||||
// --- General Settings section ---
|
||||
add_settings_section(
|
||||
'robotstxt_og_main_section',
|
||||
|
|
@ -294,6 +414,118 @@ class Robotstxt_OG_Admin_Settings {
|
|||
'robotstxt-og-settings',
|
||||
'robotstxt_og_social_section'
|
||||
);
|
||||
|
||||
// --- Platform Integration section ---
|
||||
add_settings_section(
|
||||
'robotstxt_og_platform_section',
|
||||
__( 'Platform Integration', 'robotstxt-og' ),
|
||||
array( $this, 'render_platform_section' ),
|
||||
'robotstxt-og-settings'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'robotstxt_og_fb_app_id',
|
||||
__( 'Facebook App ID', 'robotstxt-og' ),
|
||||
array( $this, 'render_fb_app_id_field' ),
|
||||
'robotstxt-og-settings',
|
||||
'robotstxt_og_platform_section'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'robotstxt_og_fb_admins',
|
||||
__( 'Facebook Admins', 'robotstxt-og' ),
|
||||
array( $this, 'render_fb_admins_field' ),
|
||||
'robotstxt-og-settings',
|
||||
'robotstxt_og_platform_section'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'robotstxt_og_fb_pages',
|
||||
__( 'Facebook Pages', 'robotstxt-og' ),
|
||||
array( $this, 'render_fb_pages_field' ),
|
||||
'robotstxt-og-settings',
|
||||
'robotstxt_og_platform_section'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'robotstxt_og_pinterest_verify',
|
||||
__( 'Pinterest Domain Verification', 'robotstxt-og' ),
|
||||
array( $this, 'render_pinterest_verify_field' ),
|
||||
'robotstxt-og-settings',
|
||||
'robotstxt_og_platform_section'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'robotstxt_og_pinterest_nopin',
|
||||
__( 'Disable Pinterest Pinning', 'robotstxt-og' ),
|
||||
array( $this, 'render_pinterest_nopin_field' ),
|
||||
'robotstxt-og-settings',
|
||||
'robotstxt_og_platform_section'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'robotstxt_og_telegram_channel',
|
||||
__( 'Telegram Channel', 'robotstxt-og' ),
|
||||
array( $this, 'render_telegram_channel_field' ),
|
||||
'robotstxt-og-settings',
|
||||
'robotstxt_og_platform_section'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'robotstxt_og_slack_app_id',
|
||||
__( 'Slack App ID', 'robotstxt-og' ),
|
||||
array( $this, 'render_slack_app_id_field' ),
|
||||
'robotstxt-og-settings',
|
||||
'robotstxt_og_platform_section'
|
||||
);
|
||||
|
||||
// --- Mobile / Web App section ---
|
||||
add_settings_section(
|
||||
'robotstxt_og_mobile_section',
|
||||
__( 'Mobile / Web App', 'robotstxt-og' ),
|
||||
array( $this, 'render_mobile_section' ),
|
||||
'robotstxt-og-settings'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'robotstxt_og_theme_color',
|
||||
__( 'Theme Color', 'robotstxt-og' ),
|
||||
array( $this, 'render_theme_color_field' ),
|
||||
'robotstxt-og-settings',
|
||||
'robotstxt_og_mobile_section'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'robotstxt_og_app_name',
|
||||
__( 'Web App Name', 'robotstxt-og' ),
|
||||
array( $this, 'render_app_name_field' ),
|
||||
'robotstxt-og-settings',
|
||||
'robotstxt_og_mobile_section'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'robotstxt_og_web_app_capable',
|
||||
__( 'PWA Standalone Mode', 'robotstxt-og' ),
|
||||
array( $this, 'render_web_app_capable_field' ),
|
||||
'robotstxt-og-settings',
|
||||
'robotstxt_og_mobile_section'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'robotstxt_og_app_status_bar_style',
|
||||
__( 'iOS Status Bar Style', 'robotstxt-og' ),
|
||||
array( $this, 'render_app_status_bar_field' ),
|
||||
'robotstxt-og-settings',
|
||||
'robotstxt_og_mobile_section'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'robotstxt_og_format_detection',
|
||||
__( 'Disable Auto Phone Detection', 'robotstxt-og' ),
|
||||
array( $this, 'render_format_detection_field' ),
|
||||
'robotstxt-og-settings',
|
||||
'robotstxt_og_mobile_section'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -529,6 +761,262 @@ class Robotstxt_OG_Admin_Settings {
|
|||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the Platform Integration section description.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_platform_section(): void {
|
||||
?>
|
||||
<p>
|
||||
<?php esc_html_e( 'Site-wide identity and verification tags for Facebook, Pinterest, Telegram, and Slack. Emitted in addition to the Open Graph / Twitter tags when no SEO plugin is handling them.', 'robotstxt-og' ); ?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a regular-text settings field for a given option.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @param string $option_name Option key.
|
||||
* @param string $placeholder Input placeholder.
|
||||
* @param string $description Field description.
|
||||
* @return void
|
||||
*/
|
||||
private function render_text_option( string $option_name, string $placeholder, string $description ): void {
|
||||
$raw = get_option( $option_name, '' );
|
||||
$value = is_string( $raw ) ? $raw : '';
|
||||
?>
|
||||
<input
|
||||
type="text"
|
||||
id="<?php echo esc_attr( $option_name ); ?>"
|
||||
name="<?php echo esc_attr( $option_name ); ?>"
|
||||
value="<?php echo esc_attr( $value ); ?>"
|
||||
placeholder="<?php echo esc_attr( $placeholder ); ?>"
|
||||
class="regular-text"
|
||||
/>
|
||||
<p class="description"><?php echo esc_html( $description ); ?></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render Facebook App ID field.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_fb_app_id_field(): void {
|
||||
$this->render_text_option( 'robotstxt_og_fb_app_id', '123456789012345', __( 'Facebook App ID, used for the fb:app_id meta tag and Insights.', 'robotstxt-og' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render Facebook Admins field.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_fb_admins_field(): void {
|
||||
$this->render_text_option( 'robotstxt_og_fb_admins', '100000000000001,100000000000002', __( 'Comma-separated Facebook user IDs of page admins (fb:admins).', 'robotstxt-og' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render Facebook Pages field.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_fb_pages_field(): void {
|
||||
$this->render_text_option( 'robotstxt_og_fb_pages', '1234567890', __( 'Facebook Page ID or comma-separated IDs (fb:pages).', 'robotstxt-og' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render Pinterest domain verification field.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_pinterest_verify_field(): void {
|
||||
$this->render_text_option( 'robotstxt_og_pinterest_verify', 'abcdef0123456789abcdef', __( 'Pinterest domain verification token (p:domain_verify).', 'robotstxt-og' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render Pinterest "disable pinning" field.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_pinterest_nopin_field(): void {
|
||||
$value = (bool) get_option( 'robotstxt_og_pinterest_nopin', false );
|
||||
?>
|
||||
<label for="robotstxt_og_pinterest_nopin">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="robotstxt_og_pinterest_nopin"
|
||||
name="robotstxt_og_pinterest_nopin"
|
||||
value="1"
|
||||
<?php checked( $value ); ?>
|
||||
/>
|
||||
<?php esc_html_e( 'Emit the Pinterest "nopin" meta tag to discourage pinning images from this site.', 'robotstxt-og' ); ?>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render Telegram channel field.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_telegram_channel_field(): void {
|
||||
$this->render_text_option( 'robotstxt_og_telegram_channel', '@channel', __( 'Telegram channel handle (telegram:channel), including the leading @.', 'robotstxt-og' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render Slack App ID field.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_slack_app_id_field(): void {
|
||||
$this->render_text_option( 'robotstxt_og_slack_app_id', 'A0123456789', __( 'Slack App ID for custom unfurls (slack-app-id).', 'robotstxt-og' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize the iOS status bar style to a safelist value.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @param mixed $value Raw value.
|
||||
* @return string
|
||||
*/
|
||||
public function sanitize_status_bar_style( $value ): string {
|
||||
$value = is_string( $value ) ? $value : '';
|
||||
$allowed = array( '', 'default', 'black', 'black-translucent' );
|
||||
|
||||
return in_array( $value, $allowed, true ) ? $value : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the Mobile / Web App section description.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_mobile_section(): void {
|
||||
?>
|
||||
<p>
|
||||
<?php esc_html_e( 'Optional mobile and Progressive Web App metadata. Tags are emitted only when configured.', 'robotstxt-og' ); ?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a checkbox settings field for a boolean option.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @param string $option_name Option key.
|
||||
* @param string $label_text Checkbox label.
|
||||
* @return void
|
||||
*/
|
||||
private function render_checkbox_option( string $option_name, string $label_text ): void {
|
||||
$value = (bool) get_option( $option_name, false );
|
||||
?>
|
||||
<label for="<?php echo esc_attr( $option_name ); ?>">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="<?php echo esc_attr( $option_name ); ?>"
|
||||
name="<?php echo esc_attr( $option_name ); ?>"
|
||||
value="1"
|
||||
<?php checked( $value ); ?>
|
||||
/>
|
||||
<?php echo esc_html( $label_text ); ?>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render theme-color field.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_theme_color_field(): void {
|
||||
$this->render_text_option( 'robotstxt_og_theme_color', '#ffffff', __( 'Hex color for the browser UI chrome (theme-color).', 'robotstxt-og' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render web app name field.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_app_name_field(): void {
|
||||
$this->render_text_option( 'robotstxt_og_app_name', 'My Site', __( 'Web app name; emitted as application-name and apple-mobile-web-app-title.', 'robotstxt-og' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the PWA standalone toggle.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_web_app_capable_field(): void {
|
||||
$this->render_checkbox_option( 'robotstxt_og_web_app_capable', __( 'Emit mobile-web-app-capable and apple-mobile-web-app-capable (standalone PWA mode).', 'robotstxt-og' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the iOS status bar style dropdown.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_app_status_bar_field(): void {
|
||||
$raw = get_option( 'robotstxt_og_app_status_bar_style', '' );
|
||||
$value = is_string( $raw ) ? $raw : '';
|
||||
$options = array(
|
||||
'' => __( 'Default (omit tag)', 'robotstxt-og' ),
|
||||
'default' => 'default',
|
||||
'black' => 'black',
|
||||
'black-translucent' => 'black-translucent',
|
||||
);
|
||||
?>
|
||||
<select name="robotstxt_og_app_status_bar_style" id="robotstxt_og_app_status_bar_style">
|
||||
<?php foreach ( $options as $val => $label ) : ?>
|
||||
<option value="<?php echo esc_attr( $val ); ?>" <?php selected( $value, $val ); ?>>
|
||||
<?php echo esc_html( $label ); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the format-detection toggle.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_format_detection_field(): void {
|
||||
$this->render_checkbox_option( 'robotstxt_og_format_detection', __( 'Emit format-detection to disable automatic phone-number linking.', 'robotstxt-og' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render settings page.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue