Your IP : 216.73.216.1
<?php
/**
* Go To Top Link
*
* @package pally
* @since 1.0.0
*/
namespace Pally;
use WP_Customize_Manager;
/**
* Go to top link
*
* @since 1.0.0
*/
class Go_To_Top {
/**
* Constructor.
*
* @since 1.0.0
* @access public
*/
public function __construct() {
add_action( 'customize_register', [ $this, 'action_register_customizer_control' ] );
}
/**
* Adds a Customizer setting, control and partial.
*
* @param WP_Customize_Manager $wp_customize Customizer manager instance.
* @since 1.0.0
* @access public
*/
public function action_register_customizer_control( WP_Customize_Manager $wp_customize ) {
$wp_customize->add_setting(
'go_to_top',
[
'default' => true,
'sanitize_callback' => 'Pally\Customizer::sanitize_checkbox',
]
);
$wp_customize->add_control(
'go_to_top',
[
'label' => __( 'Go to top link', 'pally' ),
'description' => __( 'Enable a go to top link in the site footer', 'pally' ),
'section' => 'footer_options',
'type' => 'checkbox',
]
);
$wp_customize->selective_refresh->add_partial(
'go_to_top',
[
'selector' => '.go-to-top',
'container_ally' => true,
]
);
}
/**
* Outputs the back to top text.
*
* @since 1.0.0
* @access public
*/
public static function go_to_top() {
if ( get_theme_mod( 'go_to_top', true ) === true ) {
?>
<a class="go-to-top" href="#top">
<span class="offscreen"><?php esc_html_e( 'go to top', 'pally' ); ?></span>
<span class="aticon aticon-gototop" aria-hidden="true"></span>
</a>
<?php
}
}
}