ConvertKit in the WordPress Administration
* interface, and handles saving its data.
*
* @package ConvertKit
* @author ConvertKit
*/
class ConvertKit_Admin_Settings {
/**
* Settings sections
*
* @var array
*/
public $sections = array();
/**
* Holds the Settings Page Slug
*
* @var string
*/
const SETTINGS_PAGE_SLUG = '_wp_convertkit_settings';
/**
* Constructor
*/
public function __construct() {
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
add_action( 'admin_init', array( $this, 'register_sections' ) );
add_filter( 'plugin_action_links_' . CONVERTKIT_PLUGIN_FILE, array( $this, 'add_settings_page_link' ) );
}
/**
* Enqueue JavaScript in Admin
*
* @since 1.9.6
*
* @param string $hook Hook.
*/
public function enqueue_scripts( $hook ) {
// Bail if we are not on the Settings screen.
if ( $hook !== 'settings_page_' . self::SETTINGS_PAGE_SLUG ) {
return;
}
// Get active settings section / tab that has been requested.
$section = $this->get_active_section();
/**
* Enqueue JavaScript for the Settings Screen at Settings > ConvertKit
*
* @since 1.9.6
*
* @param string $section Settings section / tab (general|tools|restrict-content).
*/
do_action( 'convertkit_admin_settings_enqueue_scripts', $section );
}
/**
* Enqueue CSS for the Settings Screens at Settings > ConvertKit
*
* @since 1.9.6
*
* @param string $hook Hook.
*/
public function enqueue_styles( $hook ) {
// Bail if we are not on the Settings screen.
if ( $hook !== 'settings_page_' . self::SETTINGS_PAGE_SLUG ) {
return;
}
// Get active settings section / tab that has been requested.
$section = $this->get_active_section();
// Always enqueue Settings CSS, as this is used for the UI across all settings sections.
wp_enqueue_style( 'convertkit-admin-settings', CONVERTKIT_PLUGIN_URL . 'resources/backend/css/settings.css', array(), CONVERTKIT_PLUGIN_VERSION );
/**
* Enqueue CSS for the Settings Screen at Settings > ConvertKit
*
* @since 1.9.6
*
* @param string $section Settings section / tab (general|tools|restrict-content).
*/
do_action( 'convertkit_admin_settings_enqueue_styles', $section );
}
/**
* Adds the options page
*
* @since 1.9.6
*/
public function add_settings_page() {
add_options_page(
__( 'ConvertKit', 'convertkit' ),
__( 'ConvertKit', 'convertkit' ),
'manage_options',
self::SETTINGS_PAGE_SLUG,
array( $this, 'display_settings_page' )
);
}
/**
* Outputs the settings screen.
*
* @since 1.9.6
*/
public function display_settings_page() {
$active_section = $this->get_active_section();
?>
get_active_section_documentation_url( $active_section ); if ( $documentation_url !== false ) { echo sprintf( '%s %s', esc_html__( 'If you need help setting up the plugin please refer to the', 'convertkit' ), esc_attr( $documentation_url ), esc_html__( 'plugin documentation', 'convertkit' ) ); } ?>