Yoast / wordpress-seo

Yoast SEO for WordPress
https://yoast.com/wordpress/plugins/seo/
Other
1.76k stars 889 forks source link

Support for WordPress Customizer for front end facing features #2356

Closed bhubbard closed 9 years ago

bhubbard commented 9 years ago

I would love it if WordPress SEO started supporting the WordPress Customizer for front end facing features, such as the Breadcrumb settings. Not sure the best place to place this code, but it would be enough to get this started.

Screenshot: Screenshot

<?php

function wpseo_customize_register( $wp_customize ) {

    // WordPress SEO Panel
    $wp_customize->add_panel( 'wpseo_panel', array(
            'priority' => '999',
            'capability' => 'edit_theme_options',
            'theme_supports' => '',
            'title' => __( 'WordPress SEO', 'wordpress-seo' ),
            'description' => __( 'Customize your WordPress SEO Settings.', 'wordpress-seo' ),
    ) );

    // Breadcrumbs Section
    $wp_customize->add_section( 'wpseo_breadcrumbs_customizer_section' , array(
            'title'      => __( 'Breadcrumbs', 'wpseo' ),
            'description' => __( 'Use this section to enable and customize breadcrumbs for your site.', 'wordpress-seo' ),
            'priority'   => 30,
            'panel' => 'wpseo_panel',
        ) );

    // Social Section
    $wp_customize->add_section( 'wpseo_social_customizer_section' , array(
            'title'      => __( 'Social', 'wpseo' ),
            'description' => __( 'Use this section to setup your yoast social settings.', 'wordpress-seo' ),
            'priority'   => 30,
            'panel' => 'wpseo_panel',
        ) );

    // Enable or Disable Breadcrumbs Settings
    $wp_customize->add_setting( 'wpseo_internallinks[breadcrumbs-enable]' , array(
            'default'     => '',
            'type' => 'option',
            'transport'   => 'refresh',
        ) );

    // Enable or Disable Breadcrumbs Controls
    $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wpseo-breadcrumbs-enable' , array(
                'label'        => __( 'Enable Breadcrumbs', 'wpseo' ),
                'description'  => __( 'Use this to enable breadcrumbs for your site.', 'wordpress-seo' ),
                'type'         => 'checkbox',
                'section'      => 'wpseo_breadcrumbs_customizer_section',
                'settings'     => 'wpseo_internallinks[breadcrumbs-enable]',
                'context'      => ''
         ) ) );

    // Bold Last Breadcrumb Setting
    $wp_customize->add_setting( 'wpseo_internallinks[breadcrumbs-boldlast]' , array(
            'default'     => '',
            'type' => 'option',
            'transport'   => 'refresh',
        ) );

    // Bold Last BreadcrumbControls
    $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wpseo-breadcrumbs-boldlast' , array(
                'label'        => __( 'Bold the last page in the breadcrumb', 'wordpress-seo' ),
                'description'  => __( 'Use this to bold the last breadcrumb.', 'wordpress-seo' ),
                'type'         => 'checkbox',
                'section'      => 'wpseo_breadcrumbs_customizer_section',
                'settings'     => 'wpseo_internallinks[breadcrumbs-boldlast]',
                'context'      => ''
         ) ) );

    // Remove Blog Breadcrumb Setting
    $wp_customize->add_setting( 'wpseo_internallinks[breadcrumbs-blog-remove]' , array(
            'default'     => '',
            'type' => 'option',
            'transport'   => 'refresh',
        ) );

    // Remove Blog Breadcrumb Controls
    $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wpseo-breadcrumbs-blog-remove' , array(
                'label'        => __( 'Remove Blog page from Breadcrumbs', 'wordpress-seo' ),
                'description'  => __( 'Use this to remove blog from breadcrumbs.', 'wordpress-seo' ),
                'type'         => 'checkbox',
                'section'      => 'wpseo_breadcrumbs_customizer_section',
                'settings'     => 'wpseo_internallinks[breadcrumbs-blog-remove]',
                'context'      => ''
         ) ) );

    // Breadcrumb Separator Setting
    $wp_customize->add_setting( 'wpseo_internallinks[breadcrumbs-sep]' , array(
            'default'     => '',
            'type' => 'option',
            'transport'   => 'refresh',
    ) );

    // Breadcrumb Separator Controls
    $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wpseo-breadcrumbs-separator' , array(
                'label'        => __( 'Breadcrumbs Separator:', 'wpseo' ),
                'description'  => __( 'Use this to set a separator between breadcrumb links.', 'wordpress-seo' ),
                'type'         => 'text',
                'section'      => 'wpseo_breadcrumbs_customizer_section',
                'settings'     => 'wpseo_internallinks[breadcrumbs-sep]',
                'context'      => ''
    ) ) );

    // Facebook Site Setting
    $wp_customize->add_setting( 'wpseo_social[facebook_site]' , array(
            'default'     => '',
            'type' => 'option',
            'transport'   => 'refresh',
    ) );

    // Facebook Site Controls
    $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wpseo-facebook-site' , array(
                'label'        => __( 'Facebook Page URL:', 'wordpress-seo' ),
                'description'  => __( 'Please provide your facebook page url.', 'wordpress-seo' ),
                'type'         => 'text',
                'section'      => 'wpseo_social_customizer_section',
                'settings'     => 'wpseo_social[facebook_site]',
                'context'      => ''
    ) ) );

}
add_action( 'customize_register', 'wpseo_customize_register' );
jdevalk commented 9 years ago

I love this idea, so let's make sure we add it in.