*/
class Amp_WP_General {
/**
* The theme that's responsible for keeping the values of theme path of the plugin.
*
* @since 1.0.0
* @access private
* @var Amp_WP_General_Theme $amp_wp_theme keep all the theme for the plugin.
*/
private $amp_wp_theme;
/**
* Initialize the class and set its properties.
*
* @since 1.0.0
* @param string $plugin_name The name of this plugin.
* @param string $version The version of this plugin.
*/
public function __construct() {
$this->amp_wp_theme = array(
'name' => 'global_theme',
'title' => __( 'Global theme', 'amp-wp' ),
'desc' => __( 'Select design for your AMP pages, from the list of AMP WP theme plugins installed and activated.
Note:The AMP WP Customizer handles the built-in display. Additional AMP WP themes can be customized using their own customizers only.', 'amp-wp' ),
'default' => 'default',
'class' => '',
'content' => array(
'attr' => array(),
'options' => array(
"default" => __('Default Theme', 'amp-wp')
)
)
);
// Filter -> Add Settings General Tab
add_filter('amp_wp_settings_tab_menus', array($this, 'amp_wp_add_general_tab') );
// Action -> Add Settings General Section
add_action('amp_wp_settings_tab_section', array($this, 'amp_wp_add_general_settings') );
// Action -> Save Settings General Section
add_action('amp_wp_save_setting_sections', array($this, 'amp_wp_save_general_settings') );
}
/**
* Add Settings General Tab.
*
* @since 1.0.4
*
* @param array $tabs Settings Tab
* @return array $tabs Merge array of Settings Tab with General Tab.
*/
public function amp_wp_add_general_tab( $tabs ) {
$tabs['general'] = esc_html__('General', 'amp-wp');
return $tabs;
}
/**
* Add Settings General Section.
*
* This function is used to display settings general section & also display
* the stored settings.
*
* @since 1.0.4
*/
public function amp_wp_add_general_settings() {
// Get Theme Name
$theme_name_value = get_option('amp_wp_theme_name') ? get_option('amp_wp_theme_name') : 'default';
require_once AMPWP_TEMPLATE_DIR_PATH . 'admin/partials/settings/amp-wp-admin-general.php';
}
/**
* Save Settings General Section.
*
* @since 1.0.4
*/
public function amp_wp_save_general_settings() {
$amp_wp_theme_name = filter_input(INPUT_POST, 'amp_wp_theme_name');
if (isset($amp_wp_theme_name)) {
// Save Custom Post Type Slug in WP Option
( !empty( $amp_wp_theme_name ) ) ? update_option('amp_wp_theme_name', sanitize_text_field( $amp_wp_theme_name ) ) : update_option('amp_wp_theme_name', '');
}
}
}
new Amp_WP_General();