settings_page = add_theme_page( __( 'Hybrid Hook', 'bioship' ), __( 'Hybrid Hook', 'bioship' ), 'edit_theme_options', 'hybrid-hook-settings', 'hybrid_hook_settings_page' ); /* Add media for the settings page. */ add_action( "load-{$hybrid_hook->settings_page}", 'hybrid_hook_admin_enqueue_style' ); add_action( "load-{$hybrid_hook->settings_page}", 'hybrid_hook_settings_page_media' ); add_action( "admin_head-{$hybrid_hook->settings_page}", 'hybrid_hook_settings_page_scripts' ); /* Load the meta boxes. */ add_action( "load-{$hybrid_hook->settings_page}", 'hybrid_hook_load_meta_boxes' ); /* Create a hook for adding meta boxes. */ add_action( "load-{$hybrid_hook->settings_page}", 'hybrid_hook_add_meta_boxes' ); } /** * Registers the Hybrid Hook settings. * @uses register_setting() to add the settings to the database. * * @since 0.2.0 */ function hybrid_hook_register_settings() { register_setting( 'hybrid_hook_plugin_settings', 'hybrid_hook_settings', 'hybrid_hook_settings_validate' ); } /** * Executes the 'add_meta_boxes' action hook because WordPress doesn't fire this on custom admin pages. * * @since 0.3.0 */ function hybrid_hook_add_meta_boxes() { global $hybrid_hook; $plugin_data = get_plugin_data( HYBRID_HOOK_DIR . 'hybrid-hook.php' ); do_action( 'add_meta_boxes', $hybrid_hook->settings_page, $plugin_data ); } /** * Loads the plugin settings page meta boxes. * * @since 0.3.0 */ function hybrid_hook_load_meta_boxes() { require_once( HYBRID_HOOK_DIR . 'meta-boxes.php' ); } /** * Function for validating the settings input from the plugin settings page. * * @since 0.2.0 */ function hybrid_hook_settings_validate( $input ) { /* Get all available hooks. */ $hooks = hybrid_hook_get_hooks(); /* Loop through each of the hooks and validate/sanitize the settings based on the current hook in the loop. */ foreach ( $hooks as $hook ) { /* Kill evil scripts if the user doesn't have the 'unfiltered_html' cap. */ if ( current_user_can( 'unfiltered_html' ) ) $settings[$hook] = $input[$hook]; else $settings[$hook] = stripslashes( wp_filter_post_kses( addslashes( $input[$hook] ) ) ); /* Only allow PHP if the current user has the 'unfiltered_html' cap. */ if ( current_user_can( 'unfiltered_html' ) && hybrid_hook_allow_php() ) $settings["{$hook}_php"] = ( isset( $input["{$hook}_php"] ) ? 1 : 0 ); else $settings["{$hook}_php"] = 0; /* Make sure the priority is an integer. */ $settings["{$hook}_priority"] = intval( $input["{$hook}_priority"] ); } /* Return the validated/sanitized settings. */ return $settings; } /** * Displays the HTML and meta boxes for the plugin settings page. * * @since 0.2.0 */ function hybrid_hook_settings_page() { global $hybrid_hook; ?>

' . sprintf( __( "The theme you're currently using is incompatible with this plugin. Hybrid Hook was designed to work with the %s theme.", 'bioship' ), '' . __( 'Hybrid', 'bioship' ) . '' ) . '

'; ?>

' . __( 'Settings saved.', 'bioship' ) . '

'; ?>
settings_page, 'normal', null ); ?>
settings_page, 'side', null ); ?>