Squarespace Crawler Settings
Settings page for the Squarespace Crawler
class Squarespace_Crawler { public function __construct() { add_action( 'admin_menu', array( $this, 'add_admin_menu' ) ); add_action( 'admin_init', array( $this, 'init_settings' ) ); } public function add_admin_menu() { add_management_page( esc_html__( 'Squarespace Crawler Settings', 'squarespace_crawler_text_domain' ), esc_html__( 'Squarespace Crawler', 'squarespace_crawler_text_domain' ), 'manage_options', 'squarespace_crawler_settings', array( $this, 'squarespace_crawler_layout' ) ); } public function init_settings() { register_setting( 'squarespace_crawler', 'squarespace_crawler_options' ); add_settings_section( 'squarespace_crawler_options_section', '', false, 'squarespace_crawler_options' ); add_settings_field( 'squarespace_url', __( 'Squarespace Site', 'squarespace_crawler_text_domain' ), array( $this, 'render_squarespace_url_field' ), 'squarespace_crawler_options', 'squarespace_crawler_options_section' ); } public function squarespace_crawler_layout() { // Check required user capability if ( !current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'squarespace_crawler_text_domain' ) ); } // Admin Page Layout echo '<div class="wrap">' . "n"; echo ' <h1>' . get_admin_page_title() . '</h1>' . "n"; echo ' <form action="options.php" method="post">' . "n"; settings_fields( 'squarespace_crawler' ); do_settings_sections( 'squarespace_crawler_options' ); submit_button(); echo ' </form>' . "n"; echo '</div>' . "n"; } function render_squarespace_url_field() { // Retrieve data from the database. $options = get_option( 'squarespace_crawler_options' ); // Set default value. $value = isset( $options['squarespace_url'] ) ? $options['squarespace_url'] : ''; // Field output. echo '<input type="url" name="squarespace_crawler_options[squarespace_url]" class="regular-text squarespace_url_field" placeholder="' . esc_attr__( 'mydomain.com', 'squarespace_crawler_text_domain' ) . '" value="' . esc_attr( $value ) . '">'; echo '<p class="description">' . __( 'URL of the Squarespace site to crawl', 'squarespace_crawler_text_domain' ) . '</p>'; } } new Squarespace_Crawler;