getAdminOptions(); } function activate() { $this->getAdminOptions(); } function iframe_defaults() { $iframeAdminOptions = array( 'securitykey' => sha1(session_id()), 'src' => 'http://www.tinywebgallery.com', 'width' => '100%', 'height' => '600', 'scrolling' => 'no', 'marginwidth' => '0', 'marginheight' => '0', 'frameborder' => '0', 'transparency' => 'true', 'content_id' => '', 'content_styles' => '', 'hide_elements' => '', 'class' => '', 'shortcode_attributes' => 'true', 'url_forward_parameter' => '', 'id' => 'advanced_iframe', 'name' => '', 'onload' => '', 'onload_resize' => 'false', 'onload_scroll_top' => 'false', 'additional_js' => '', 'additional_css' => '', 'store_height_in_cookie' => 'false', 'additional_height' => '0', 'iframe_content_id' => '', 'iframe_content_styles' => '', 'iframe_hide_elements' => '', 'version_counter' => '1', 'onload_show_element_only' => '' ); return $iframeAdminOptions; } function getAdminOptions() { $iframeAdminOptions = advancediFrame::iframe_defaults(); $devOptions = get_option("advancediFrameAdminOptions"); if (!empty($devOptions)) { foreach ($devOptions as $key => $option) $iframeAdminOptions[$key] = $option; } update_option("advancediFrameAdminOptions", $iframeAdminOptions); return $iframeAdminOptions; } function loadLanguage() { load_plugin_textdomain('advanced-iframe', false, dirname(plugin_basename(__FILE__)) . '/languages/'); wp_enqueue_script('jquery'); } /* CSS for the admin area */ function addAdminHeaderCode() { echo '' . "\n"; echo '' . "\n"; } /* additional CSS for wp area */ function addWpHeaderCode($atts) { $options = get_option('advancediFrameAdminOptions'); // defaults extract(array('additional_css' => $options['additional_css'], 'additional_js' => $options['additional_js'], 'version_counter' => $options['version_counter'], $atts)); // read the shortcode attributes if ($options['shortcode_attributes'] == 'true') { extract(shortcode_atts(array('additional_css' => $options['additional_css'], 'additional_js' => $options['additional_js']), $atts)); } if ($additional_css != '') { wp_register_style( 'additional-advanced-iframe', $additional_css, false, $version_counter); wp_enqueue_style( 'additional-advanced-iframe' ); // wp_enqueue_style( 'additional-advanced-iframe', $additional_css , false ); } if ($additional_js != '' && version_compare(get_bloginfo('version'), '3.3') < 0 ) { // wp < 3.3 wp_register_script( 'additional-advanced-iframe', $additional_js, false, $version_counter); wp_enqueue_script( 'additional-advanced-iframe'); } } function param($param, $content = null) { $value = isset($_GET[$param]) ? $_GET[$param] : ''; return esc_html($value); } function do_iframe_script($atts) { $options = get_option('advancediFrameAdminOptions'); // defaults for new settings in 2.0 if (!isset ($options['id'])) { $options['id'] = ''; } if (!isset ($options['name'])) { $options['name'] = ''; } if (!isset ($options['onload'])) { $options['onload'] = ''; } if (!isset ($options['onload_resize'])) { $options['onload_resize'] = 'false'; } if (!isset ($options['onload_scroll_top'])) { $options['onload_scroll_top'] = 'false'; } if (!isset ($options['additional_js'])) { $options['additional_js'] = ''; } if (!isset ($options['additional_css'])) { $options['additional_css'] = ''; } if (!isset ($options['store_height_in_cookie'])) { $options['store_height_in_cookie'] = 'false'; } if (!isset ($options['additional_height'])) { $options['additional_height'] = 0; } if (!isset ($options['iframe_content_id'])) { $options['iframe_content_id'] = ''; } if (!isset ($options['iframe_content_styles'])) { $options['iframe_content_styles'] = ''; } if (!isset ($options['iframe_hide_elements'])) { $options['iframe_hide_elements'] = ''; } if (!isset ($options['version_counter'])) { $options['version_counter'] = '1'; } if (!isset ($options['onload_show_element_only'])) { $options['onload_show_element_only'] = ''; } // defaults from main config extract(array('securitykey' => 'not set', 'src' => $options['src'], 'height' => $options['height'], 'width' => $options['width'], 'frameborder' => $options['frameborder'], 'scrolling' => $options['scrolling'], 'marginheight' => $options['marginheight'], 'marginwidth' => $options['marginwidth'], 'transparency' => $options['transparency'], 'content_id' => $options['content_id'], 'content_styles' => $options['content_styles'], 'hide_elements' => $options['hide_elements'], 'class' => $options['class'], 'url_forward_parameter' => $options['url_forward_parameter'], 'id' => $options['id'], 'name' => $options['name'], 'onload' => $options['onload'], 'onload_resize' => $options['onload_resize'], 'onload_scroll_top'=> $options['onload_scroll_top'], 'additional_js'=> $options['additional_js'], 'additional_css'=> $options['additional_css'], 'store_height_in_cookie'=> $options['store_height_in_cookie'], 'additional_height' => $options['additional_height'], 'iframe_content_id' => $options['iframe_content_id'], 'iframe_content_styles' => $options['iframe_content_styles'], 'iframe_hide_elements' => $options['iframe_hide_elements'], 'version_counter' => $options['version_counter'], 'onload_show_element_only' => $options['onload_show_element_only'], $atts)); // read the shortcode attributes if ($options['shortcode_attributes'] == 'true') { // src value can be hidden in [0] and [1] if the editor does hotlink the url. Therefore I look in there if the src is not set! if (!isset($atts['src'])) { if (isset($atts[0]) && (stristr($atts[0], 'src') !== FALSE)) { if (isset($atts[1])) { $input = ']*?)\\1[^>]*>(.*)<\/a>"; if(preg_match_all("/$regexp/siU", $input, $matches)) { if (isset($matches[2])) { $atts['src'] = $matches[2][0]; } } } } } extract(shortcode_atts(array('securitykey' => 'not set', 'src' => $options['src'], 'height' => $options['height'], 'width' => $options['width'], 'frameborder' => $options['frameborder'], 'scrolling' => $options['scrolling'], 'marginheight' => $options['marginheight'], 'marginwidth' => $options['marginwidth'], 'transparency' => $options['transparency'], 'content_id' => $options['content_id'], 'content_styles' => $options['content_styles'], 'hide_elements' => $options['hide_elements'], 'class' => $options['class'], 'url_forward_parameter' => $options['url_forward_parameter'], 'id' => $options['id'], 'name' => $options['name'], 'onload' => $options['onload'], 'onload_resize' => $options['onload_resize'], 'onload_scroll_top'=> $options['onload_scroll_top'], 'additional_js'=> $options['additional_js'], 'additional_css'=> $options['additional_css'], 'store_height_in_cookie'=> $options['store_height_in_cookie'], 'additional_height' => $options['additional_height'], 'iframe_content_id' => $options['iframe_content_id'], 'iframe_content_styles' => $options['iframe_content_styles'], 'iframe_hide_elements' => $options['iframe_hide_elements'], 'onload_show_element_only' => $options['onload_show_element_only'], ) , $atts)); } else { // only the secrity key is read. extract(shortcode_atts(array('securitykey' => 'not set'), $atts)); } if (empty ($id)) { $id = 'advanced_iframe'; } if (empty ($name)) { $name = 'advanced_iframe'; } echo '' . "\n"; echo '' . "\n"; if ($store_height_in_cookie == 'true') { echo ''; } if ($additional_height != 0) { echo ''; } echo '' . "\n"; if ($options['securitykey'] != $securitykey) { echo '
' . __('An invalid security key was specified. Please use at least the following shortcode:
[advanced_iframe securitykey="<your security key - see settings>"]. Please also check in the html mode that your shortcode does only contain notmal spaces and not a &nbsp; instead.', 'advanced-iframe') . '
'; return; } else { // add parameters if ($url_forward_parameter != '') { $sep = "&"; if (strpos($src, '?') === false) { $sep = '?'; } $parameters = explode(",", $url_forward_parameter); foreach ($parameters as $parameter) { $read_param_esc = $this->param($parameter); if ($read_param_esc != '') { $src .= $sep . $parameter . "=" . $read_param_esc; $sep = "&"; } } } $html = ''; if ((!empty($content_id) && !empty($content_styles)) || !empty($hide_elements)) { // hide elements is called directy in the page to hide elements as fast as quickly $hidehtml = ''; if (!empty($hide_elements)) { $hidehtml .= "jQuery('" . esc_html($hide_elements) . "').css('display', 'none');"; } if (!empty($content_id)) { $elements = esc_html($content_id); // this field should not have a problem if they are encoded. $values = esc_html($content_styles); // this field style should not have a problem if they are encoded. $elementArray = explode("|", $elements); $valuesArray = explode("|", $values); if (count($elementArray) != count($valuesArray)) { echo '
' . __('Configuration error: The attributes content_id and content_styles have to have the amount of value sets separated by |.', 'advanced-iframe') . '
'; return; } else { for ($x = 0; $x < count($elementArray); ++$x) { $valuesArrayPairs = explode(";", trim($valuesArray[$x], " ;:")); for ($y = 0; $y < count($valuesArrayPairs); ++$y) { $elements = explode(":", $valuesArrayPairs[$y]); $hidehtml .= "jQuery('" . $elementArray[$x] . "').css('" . $elements[0] . "', '" . $elements[1] . "');"; } } } } $html .= ''; } // jQuery("#advanced_iframe").contents().find("#iframe-div").css("border","4px solid blue"); $hideiframehtml = ''; if ((!empty($iframe_content_id) && !empty($iframe_content_styles))|| !empty($iframe_hide_elements)) { // hide elements is called directy in the page to hide elements as fast as quickly $hideiframehtml = ''; if (!empty($iframe_hide_elements)) { $hideiframehtml .= "jQuery('#".$id."').contents().find('" . esc_html($iframe_hide_elements) . "').css('display', 'none');"; } if (!empty($iframe_content_id)) { $elements = esc_html($iframe_content_id); // this field should not have a problem if they are encoded. $values = esc_html($iframe_content_styles); // this field style should not have a problem if they are encoded. $elementArray = explode("|", $elements); $valuesArray = explode("|", $values); if (count($elementArray) != count($valuesArray)) { echo '
' . __('Configuration error: The attributes iframe_content_id and iframe_content_styles have to have the amount of value sets separated by |.', 'advanced-iframe') . '
'; return; } else { for ($x = 0; $x < count($elementArray); ++$x) { $valuesArrayPairs = explode(";", trim($valuesArray[$x], " ;:")); for ($y = 0; $y < count($valuesArrayPairs); ++$y) { $elements = explode(":", $valuesArrayPairs[$y]); $hideiframehtml .= "jQuery('#".$id."').contents().find('" . $elementArray[$x] . "').css('" . $elements[0] . "', '" . $elements[1] . "');"; } } } } if ($hideiframehtml != '') { $html .= ''; } } $html .= "