'Auto iFrame', // Icon/image for shortcode. Optional. src or dashicons-$icon. Defaults to carrot. 'listItemImage' => '', // Available shortcode attributes and default values. Required. Array. // Attribute model expects 'attr', 'type' and 'label' // Supported field types: text, checkbox, textarea, radio, select, email, url, number, and date. 'attrs' => array( array( 'label' => 'url', 'attr' => 'url', 'type' => 'url', 'description' => 'The remote URL of the site to create the iFrame for.', 'meta' => array('size'=>'45'), ), array( 'label' => 'id', 'attr' => 'id', 'type' => 'text', 'description' => 'An optional tag to set the id of the iFrame to if you are including multiple iFrames on the same page.', 'meta' => array('size'=>'15'), ), array( 'label' => 'Width', 'attr' => 'width', 'type' => 'text', 'description' => 'The width of the iFrame, percentage or px.', 'meta' => array('size'=>'5'), ), array( 'label' => 'Height', 'attr' => 'height', 'type' => 'text', 'description' => 'The height of the iFrame, percentage or px. This will be the initial height if auto size is enabled.', 'meta' => array('size'=>'5'), ), array( 'label' => 'Autosize', 'attr' => 'autosize', 'type' => 'radio', 'description' => 'Enable the automatic resize of the height of the iFrame based on content.', 'options' => array( 'yes' => 'Yes', 'no' => 'No'), ), array( 'label' => 'Fudge Factor', 'attr' => 'fudge', 'type' => 'text', 'description' => 'A fudge factor to apply when changing the height (integer number, no "px").', 'meta' => array( 'size' => 5 ), ), array( 'label' => 'Border', 'attr' => 'border', 'type' => 'text', 'description' => 'Enable the border on the iFrame.', 'meta' => array( 'size' => 5 ), ), ), ) ); } } function auto_iframe_shortcode( $atts ) { /* 3Dvo-model shortcode is in the format of: [3Dvo-model url=xxx id=xxx width=xxx height=xxx autosize=yes/no] Where: url = the url of the source for the iFrame. REQUIRED. id = a unique identifier in case you want more than one iFrame on a page. Default = 3Dvo-model. width = width of the iFrame (100% by default). Can be % or px. Default = 100%. height = the initial height of the iframe (100% by default). Can be % or px. Default = 100%. autosize = enable the auto sizing of the iFrame based on the content. The initial height of the iFrame will be set to "height" and then resized. Default = true. fudge = a fudge factor to apply when changing the height (integer number, no "px"). Default = 50. border = enable the border on the iFrame. Default = 0. scroll = enable the scroll bar on the iFrame. Default = no. */ // We don't have any parameters, just return a blank string. if( !is_array( $atts ) ) { return ''; } // Get url. $url = ''; if( array_key_exists( 'url', $atts ) ) { $url = htmlentities(trim( $atts['url'] ), ENT_QUOTES ); } // If no link has been passed in, there's nothing to do so just return a blank string. if( $url == '' ) { return ''; } // Get the rest of the attributes. $id = '3Dvo-model'; if( array_key_exists( 'id', $atts ) ) { $id = htmlentities(trim( $atts['id'] ), ENT_QUOTES ); } $width = '100%'; if( array_key_exists( 'width', $atts ) ) { $width = htmlentities(trim( $atts['width'] ), ENT_QUOTES ); } $height = 'auto'; if( array_key_exists( 'height', $atts ) ) { $height = htmlentities(trim( $atts['height'] ), ENT_QUOTES ); } $autosize = true; if( array_key_exists( 'autosize', $atts ) ) { if( strtolower( $atts['autosize'] ) != 'yes' ) { $autosize = false; } ; } $fudge = 50; if( array_key_exists( 'fudge', $atts ) ) { $fudge = intval( $atts['fudge'] ); } $border = '0'; if( array_key_exists( 'border', $atts ) ) { $border = htmlentities(trim( $atts['border'] ), ENT_QUOTES ); } $scroll = 'no'; if( array_key_exists( 'scroll', $atts ) ) { if( strtolower( $atts['autosize'] ) != 'yes' ) { $scroll = 'yes'; } ; } if( $autosize ) { // Enqueue the javascript and jquery code. wp_enqueue_script( 'resize3Dvo_js', plugins_url( 'resize3Dvo.js', __FILE__ ), array( 'jquery' ) ); $result = '' . "\n"; } $result .= ''; return $result; } // EOF