Settings


Theme4Press Themes
', 'evolve' ), 'updated fade' ); return evl_get_default_values(); } /* * Udpdate Settings. */ if ( isset( $_POST['update'] ) ) { $clean = array(); $options = evolve_options(); foreach ( $options as $option ) { if ( ! isset( $option['id'] ) ) { continue; } if ( ! isset( $option['type'] ) ) { continue; } $id = preg_replace( '/[^a-zA-Z0-9._\-]/', '', strtolower( $option['id'] ) ); // Set checkbox to false if it wasn't sent in the $_POST if ( 'checkbox' == $option['type'] && ! isset( $input[$id] ) ) { $input[$id] = '0'; } // Set each item in the multicheck to false if it wasn't sent in the $_POST if ( 'multicheck' == $option['type'] && ! isset( $input[$id] ) ) { foreach ( $option['options'] as $key => $value ) { $input[$id][$key] = '0'; } } // For a value to be submitted to database it must pass through a sanitization filter if ( has_filter( 'evl_sanitize_' . $option['type'] ) ) { $clean[$id] = apply_filters( 'evl_sanitize_' . $option['type'], $input[$id], $option ); } } add_settings_error( 'theme_options', 'save_options', __( '
Options Updated
', 'evolve' ), 'updated fade' ); return $clean; } /* * Request Not Recognized. */ return evl_get_default_values(); } /** * Format Configuration Array. * * Get an array of all default values as set in * options.php. The 'id','std' and 'type' keys need * to be defined in the configuration array. In the * event that these keys are not present the option * will not be included in this function's output. * * @return array Rey-keyed options configuration array. * * @access private */ function evl_get_default_values() { $output = array(); $config = evolve_options(); foreach ( (array) $config as $option ) { if ( ! isset( $option['id'] ) ) { continue; } if ( ! isset( $option['std'] ) ) { continue; } if ( ! isset( $option['type'] ) ) { continue; } if ( has_filter( 'evl_sanitize_' . $option['type'] ) ) { $output[$option['id']] = apply_filters( 'evl_sanitize_' . $option['type'], $option['std'], $option ); } } return $output; } /** * Add Theme Options menu item to Admin Bar. */ add_action( 'wp_before_admin_bar_render', 'evolve_adminbar' ); function evolve_adminbar() { global $wp_admin_bar; $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'evl_theme_options', 'title' => __( 'Theme Options', 'evolve' ), 'href' => admin_url( 'themes.php?page=theme_options' ) )); } if ( ! function_exists( 'evl_get_option' ) ) { /** * Get Option. * * Helper function to return the theme option value. * If no value has been saved, it returns $default. * Needed because options are as serialized strings. */ function evl_get_option( $name, $default = false ) { $config = get_option( 'evolve' ); if ( ! isset( $config['id'] ) ) { return $default; } $options = get_option( $config['id'] ); if ( isset( $options[$name] ) ) { return $options[$name]; } return $default; } }