$cm_theme ) ); } /** * Settings Page * Adds Admin Menu Item via WordPress' "Administration Menus" API. Also hook actions to register options via WordPress' Settings API. */ static function admin_load() { // added here to not effect other pages. add_filter( 'sns_options_pre_update_option', array( __CLASS__, 'new_hoops') ); register_setting( SnS_Admin::OPTION_GROUP, 'SnS_options' ); add_settings_section( 'hoops_section', __( 'The Hoops Shortcodes', 'scripts-n-styles' ), array( __CLASS__, 'hoops_section' ), SnS_Admin::MENU_SLUG ); } static function new_hoops( $options ) { // Get Hoops. (Shouldn't be empty.) $hoops = $options[ 'hoops' ]; /* add_settings_error( 'sns_hoops', 'settings_updated', '
'
			. '$hoops '
			. print_r(
			$hoops, true ) . '
', 'updated' ); */ // take out new. (Also shouldn't be empty.) $new = $hoops[ 'new' ]; unset( $hoops[ 'new' ] ); // Get Shortcodes. (Could be empty.) $shortcodes = empty( $hoops[ 'shortcodes' ] ) ? array() : $hoops[ 'shortcodes' ]; // prune shortcodes with blank values. foreach( $shortcodes as $key => $value ){ if ( empty( $value ) ) unset( $shortcodes[ $key ] ); } // Add new (if not empty). if ( ! empty( $new[ 'code' ] ) ) { $name = empty( $new[ 'name' ] ) ? '' : $new[ 'name' ]; if ( '' == $name ) { // If blank, find next index.. $name = 0; while ( isset( $shortcodes[ $name ] ) ) $name++; } else if ( isset( $shortcodes[ $name ] ) ) { // To make sure not to overwrite. $countr = 1; while ( isset( $shortcodes[ $name . '_' . $countr ] ) ) $countr++; $name .= '_' . $countr; } // Add new to shortcodes. $shortcodes[ $name ] = $new[ 'code' ]; } // Put in Shortcodes... if not empty. if ( empty( $shortcodes ) ) { if ( isset( $hoops[ 'shortcodes' ] ) ) unset( $hoops[ 'shortcodes' ] ); } else { $hoops[ 'shortcodes' ] = $shortcodes; } // Put in Hoops... if not empty. if ( empty( $hoops ) ) { if ( isset( $options[ 'hoops' ] ) ) unset( $options[ 'hoops' ] ); } else { $options[ 'hoops' ] = $hoops; } return $options; // Finish Filter. } /** * Settings Page * Outputs Description text for the Global Section. */ static function hoops_section() { echo '
'; _e( '

"Hoops" are shortcodes invented to get around some limitations of vanilla WordPress.

' . '

Normally, certain HTML is very problematic to use in the Post Editor, because it either gets ' . 'jumbled during Switching between HTML and Visual Tabs, stripped out by WPAutoP (rare) or stripped ' . 'out because the User doesn’t have the proper Permissions.

' . '

With Hoops, an Admin user (who has `unfiltered_html` and `manage_options` capablilities) can ' . 'write and approve snippets of HTML for other users to use via Shortcodes.

', 'scripts-n-styles' ); echo '
'; $options = get_option( 'SnS_options' ); $meta_name = 'SnS_options[hoops]'; $hoops = isset( $options[ 'hoops' ] ) ? $options[ 'hoops' ] : array(); $shortcodes = isset( $hoops[ 'shortcodes' ] ) ? $hoops[ 'shortcodes' ] : array(); ?>

Add New:

Add New

Existing Codes:

$value ) { ?>

[hoops name=""]