*/ class CustomHeaderFooterSettings extends CustomHeaderFooterModel { public function __construct() { // this should be first so the default values get stored $this->custom_header_footer_settings(); parent::__construct( (array) get_option( $this->prefix ) ); } public function get_defaults() { return [ 'custom_scripts' => array( 'title' => '', 'display_on' => 'full_site', 'custom_posts' => '', 'custom_category' => '', 'custom_post_types' => '', 'custom_pages' => '', 'custom_tags' => '', 'location' => 'header', 'device_type' => 'all_devices', 'script_type' => 'css', 'custom_js' => '', 'custom_css' => '', ), ]; } /** * Settings Fields * * @return void */ public function custom_header_footer_setting_fields( &$fields ) { $fields[] = array( 'id' => 'title', 'type' => 'text', 'title' => __( 'Snippet Title', WP_ADMINIFY_TD ), 'default' => $this->get_default_field( 'custom_scripts' )['title'], ); $fields[] = array( 'id' => 'display_on', 'type' => 'select', 'title' => __( 'Display on', WP_ADMINIFY_TD ), 'placeholder' => __( 'Select an option', WP_ADMINIFY_TD ), 'options' => array( 'full_site' => __( 'Full Site', WP_ADMINIFY_TD ), 'posts_pro' => __( 'Specific Posts (Pro)', WP_ADMINIFY_TD ), 'pages_pro' => __( 'Specific Page (Pro)', WP_ADMINIFY_TD ), 'categories_pro' => __( 'Specific Categories (Pro)', WP_ADMINIFY_TD ), 'custom_posts_pro' => __( 'Specific Post Types (Pro)', WP_ADMINIFY_TD ), 'tags_pro' => __( 'Specific Tags (Pro)', WP_ADMINIFY_TD ), ), 'default' => $this->get_default_field( 'custom_scripts' )['display_on'], ); $fields[] = array( 'id' => 'location', 'type' => 'button_set', 'title' => __( 'Location', WP_ADMINIFY_TD ), 'options' => array( 'header' => __( 'Header', WP_ADMINIFY_TD ), 'footer' => __( 'Footer', WP_ADMINIFY_TD ), 'content_before_pro' => __( 'Before Content (Pro)', WP_ADMINIFY_TD ), 'content_after_pro' => __( 'After Content (Pro)', WP_ADMINIFY_TD ), ), 'default' => $this->get_default_field( 'custom_scripts' )['location'], ); $fields[] = array( 'id' => 'device_type_notice', 'type' => 'notice', 'title' => __( 'Display Device', WP_ADMINIFY_TD ), 'style' => 'warning', 'content' => Utils::adminify_upgrade_pro(), ); $fields[] = array( 'id' => 'script_type', 'type' => 'button_set', 'title' => __( 'Snippet Type', WP_ADMINIFY_TD ), 'options' => array( 'css' => 'CSS', 'js' => 'JS', ), 'default' => $this->get_default_field( 'custom_scripts' )['script_type'], ); $fields[] = array( 'id' => 'custom_js', 'type' => 'code_editor', 'title' => __( 'Custom JavaScript', WP_ADMINIFY_TD ), 'subtitle' => __( 'Add your Custom Script here', WP_ADMINIFY_TD ), 'settings' => array( 'theme' => 'dracula', 'mode' => 'javascript', ), 'dependency' => array( 'script_type', '==', 'js' ), 'default' => $this->get_default_field( 'custom_scripts' )['custom_js'], ); $fields[] = array( 'id' => 'custom_css', 'type' => 'code_editor', 'title' => __( 'Custom CSS', WP_ADMINIFY_TD ), 'subtitle' => __( 'Add your Custom CSS here', WP_ADMINIFY_TD ), 'settings' => array( 'theme' => 'mbo', 'mode' => 'css', ), 'dependency' => array( 'script_type', '==', 'css' ), 'default' => $this->get_default_field( 'custom_scripts' )['custom_css'], ); } public function custom_header_footer_settings() { if ( !class_exists( 'ADMINIFY' ) ) { return; } // WP Adminify Custom Header & Footer Options \ADMINIFY::createOptions( $this->prefix, array( 'framework_title' => 'WP Adminify Custom CSS/JS by WP Adminify', 'framework_class' => 'adminify-custom-css-js', 'menu_title' => 'Custom CSS / JS', 'menu_slug' => 'adminify-custom-css-js', 'menu_type' => 'submenu', 'menu_capability' => 'manage_options', 'menu_icon' => '', 'menu_position' => 54, 'menu_hidden' => false, 'menu_parent' => 'wp-adminify-settings', 'footer_text' => ' ', 'footer_after' => ' ', 'footer_credit' => ' ', 'show_bar_menu' => false, 'show_sub_menu' => false, 'show_in_network' => false, 'show_in_customizer' => false, 'show_search' => false, 'show_reset_all' => false, 'show_reset_section' => false, 'show_footer' => true, 'show_all_options' => true, 'show_form_warning' => true, 'sticky_header' => false, 'save_defaults' => true, 'ajax_save' => true, 'admin_bar_menu_icon' => '', 'admin_bar_menu_priority' => 45, 'database' => 'options', 'transient_time' => 0, 'enqueue_webfont' => true, 'async_webfont' => false, 'output_css' => false, 'nav' => 'normal', 'theme' => 'dark', 'class' => 'wp-adminify-custom-css-js', ) ); $fields = []; $this->custom_header_footer_setting_fields( $fields ); // Custom CSS/JS Settings \ADMINIFY::createSection( $this->prefix, array( 'title' => __( 'Others', WP_ADMINIFY_TD ), 'icon' => 'fas fa-bolt', 'fields' => [ [ 'type' => 'subheading', 'content' => Utils::adminfiy_help_urls( __( 'Header/Footer Snippets', WP_ADMINIFY_TD ), 'https://wpadminify.com/kb/how-to-add-custom-css-or-js-in-full-site-or-specific-page/', 'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', 'https://www.facebook.com/groups/jeweltheme', 'https://wpadminify.com/support/header-footer-scripts/' ), ], [ 'id' => 'custom_scripts', 'type' => 'group', 'title' => '', 'accordion_title_prefix' => __( 'Snippet Name: ', WP_ADMINIFY_TD ), 'accordion_title_number' => true, 'accordion_title_auto' => true, 'button_title' => __( 'Add New Snippet', WP_ADMINIFY_TD ), 'fields' => $fields, ] ], ) ); } }