Created
September 2, 2015 14:14
-
-
Save Chrisedmo/b15fc76b9e8141bd52c9 to your computer and use it in GitHub Desktop.
Revolution Slider - Option Tree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Revolution Slider option type. | |
* | |
* See @ot_display_by_type to see the full list of available arguments. | |
* | |
* @param array An array of arguments. | |
* @return string | |
* | |
* @access public | |
* @since 2.0 | |
*/ | |
if ( ! function_exists( 'ot_type_revolution_slider' ) ) { | |
function ot_type_revolution_slider( $args = array() ) { | |
/* turns arguments array into variables */ | |
extract( $args ); | |
/* verify a description */ | |
$has_desc = $field_desc ? true : false; | |
/* format setting outer wrapper */ | |
echo '<div class="format-setting type-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">'; | |
/* description */ | |
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : ''; | |
/* format setting inner wrapper */ | |
echo '<div class="format-setting-inner">'; | |
/* build select */ | |
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">'; | |
echo '<option value="">-- Select Slider --</option>'; | |
global $wpdb; | |
// Query wp_revslider_sliders table to get alias's | |
$revolution_sliders = $wpdb->get_results("SELECT alias FROM wp_revslider_sliders"); | |
// Loop through object to display alias's | |
foreach($revolution_sliders as $slider){ | |
echo '<option value="'.esc_attr($slider->alias).'" '.selected( $field_value, $slider->alias, false ).'>'.$slider->alias.'</option>'; | |
} | |
echo '</select>'; | |
echo '</div>'; | |
echo '</div>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment