Changeset 1186627
- Timestamp:
- 06/24/2015 06:04:04 AM (11 years ago)
- File:
-
- 1 edited
-
edshelf-widget/trunk/edshelf-widgets.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
edshelf-widget/trunk/edshelf-widgets.php
r1186621 r1186627 73 73 * Returns the Shelf widget itself 74 74 */ 75 function edshelf_shelf_widget_embed( $id = EDSHELF_DEFAULT_SHELF_ID, $height = EDSHELF_DEFAULT_SHELF_HEIGHT, $format = EDSHELF_DEFAULT_SHELF_FORMAT ) {75 function edshelf_shelf_widget_embed( $id = EDSHELF_DEFAULT_SHELF_ID, $height = EDSHELF_DEFAULT_SHELF_HEIGHT, $format = EDSHELF_DEFAULT_SHELF_FORMAT, $which = 's' ) { 76 76 $id = esc_attr( $id ); 77 77 $height = esc_attr( $height ); 78 78 $format = esc_attr( $format ); 79 return "<div id='edshelf-widget-shelf-{$id}'></div><script src='https://edshelf.com/widgets/shelf/?id={$id}&height={$height}&format={$format}&type=shelf'></script>"; 79 $which = ( $which == 'c' ) ? 'collection' : 'shelf'; 80 return "<div id='edshelf-widget-shelf-{$id}'></div><script src='https://edshelf.com/widgets/{$which}/?id={$id}&height={$height}&format={$format}&type=shelf'></script>"; 80 81 } 81 82 … … 95 96 * 96 97 * [edshelf-shelf-widget id="33080" height="550" format="grid"] 97 * [edshelf-shelf-widget id="33080" height="550" format="grid"] // Legacy shortcode98 98 */ 99 99 add_shortcode( 'edshelf-shelf-widget', 'edshelf_shelf_widget_function' ); 100 add_shortcode( 'edshelf-collection-widget', 'edshelf_shelf_widget_function' ); // Legacy shortcode101 100 function edshelf_shelf_widget_function( $atts ) { 102 101 extract( shortcode_atts( array( … … 107 106 108 107 return edshelf_shelf_widget_embed( $id, $height, $format ); 108 } 109 110 111 /** 112 * Creates a legacy shortcode for the Shelf widget 113 * 114 * [edshelf-collection-widget id="33080" height="550" format="grid"] 115 */ 116 add_shortcode( 'edshelf-collection-widget', 'edshelf_collection_widget_function' ); 117 function edshelf_collection_widget_function( $atts ) { 118 extract( shortcode_atts( array( 119 'id' => EDSHELF_DEFAULT_SHELF_ID, 120 'height' => EDSHELF_DEFAULT_SHELF_HEIGHT, 121 'format' => EDSHELF_DEFAULT_SHELF_FORMAT 122 ), $atts ) ); 123 124 return edshelf_shelf_widget_embed( $id, $height, $format, 'c' ); 109 125 } 110 126
Note: See TracChangeset
for help on using the changeset viewer.