/** * Description here. * */ function dt_stylesheet_get_image($img_1, $img_2 = '', $use_second_img = false) { if ((!$img_1 || 'none' == $img_1) && (!$img_2 || 'none' == $img_2)) { return 'none'; } if ((!$img_1 || 'none' == $img_1) && !$use_second_img) { return "none"; } $output = dt_get_of_uploaded_image($img_1); if ($use_second_img && $img_2) { if (!parse_url($img_2, PHP_URL_SCHEME)) { $output = dt_get_of_uploaded_image($img_2); } else { $output = $img_2; } } $output = sprintf("url('%s')", esc_url($output)); return $output; }
function presscore_icons_for_handhelded_devices() { $icon_link_tpl = '<link rel="apple-touch-icon"%2$s href="%1$s">'; $old_iphone_icon = dt_get_of_uploaded_image(of_get_option('general-handheld_icon-old_iphone', '')); if ($old_iphone_icon) { printf($icon_link_tpl, esc_url($old_iphone_icon), ''); } $old_ipad_icon = dt_get_of_uploaded_image(of_get_option('general-handheld_icon-old_ipad', '')); if ($old_ipad_icon) { printf($icon_link_tpl, esc_url($old_ipad_icon), ' sizes="76x76"'); } $retina_iphone_icon = dt_get_of_uploaded_image(of_get_option('general-handheld_icon-retina_iphone', '')); if ($retina_iphone_icon) { printf($icon_link_tpl, esc_url($retina_iphone_icon), ' sizes="120x120"'); } $retina_ipad_icon = dt_get_of_uploaded_image(of_get_option('general-handheld_icon-retina_ipad', '')); if ($retina_ipad_icon) { printf($icon_link_tpl, esc_url($retina_ipad_icon), ' sizes="152x152"'); } }
/** * Parse str to array with src, width and height * expample: image.jpg?w=25&h=45 * * @param $str string * * @return array * * @since presscore 0.1 */ function dt_parse_of_uploaded_image_src ( $str ) { if ( empty( $str ) ) { return array(); } $res_arr = array(); $str_arr = explode( '?', $str ); $res_arr[0] = dt_get_of_uploaded_image( current( $str_arr ) ); // if no additional arguments specified if ( ! isset( $str_arr[1] ) ) { return array(); } $args_arr = array(); wp_parse_str( $str_arr[1], $args_arr ); if ( isset( $args_arr['w'] ) && isset( $args_arr['h'] ) ) { $res_arr[1] = intval( $args_arr['w'] ); $res_arr[2] = intval( $args_arr['h'] ); } else { return array(); } return $res_arr; }
function optionsframework_uploader($_id, $_value, $_mode = 'uri_only', $_desc = '', $_name = '') { $optionsframework_settings = get_option('optionsframework'); // Gets the unique option id $option_name = $optionsframework_settings['id']; $output = ''; $id = ''; $class = ''; $int = ''; $value = ''; $name = ''; $att_id = 0; $id = strip_tags(strtolower($_id)); // If a value is passed and we don't have a stored value, use the value that's passed through. if (!empty($_value)) { $value = $_value; // In case it's array if (is_array($value)) { $att_id = !empty($value[1]) ? absint($value[1]) : 0; $value = !empty($value[0]) ? $value[0] : ''; } } if (empty($_mode)) { $_mode = 'uri_only'; } if ($_name != '') { $name = $_name; } else { $name = $option_name . '[' . $id . ']'; } if ($value) { $class = ' has-file'; } $uploader_name = $name; if ('full' == $_mode) { $uploader_name .= '[uri]'; $output .= '<input type="hidden" class="upload-id" name="' . $name . '[id]" value="' . $att_id . '" />' . "\n"; } $output .= '<input id="' . $id . '" class="upload' . $class . '" type="text" name="' . $uploader_name . '" value="' . $value . '" placeholder="' . __('No file chosen', 'the7mk2') . '" readonly="readonly"/>' . "\n"; if (function_exists('wp_enqueue_media')) { if ($value == '') { $output .= '<input id="upload-' . $id . '" class="upload-button uploader-button button" type="button" value="' . __('Upload', 'the7mk2') . '" />' . "\n"; } else { $output .= '<input id="remove-' . $id . '" class="remove-file uploader-button button" type="button" value="' . __('Remove', 'the7mk2') . '" />' . "\n"; } } else { $output .= '<p><i>' . __('Upgrade your version of WordPress for full media support.', 'the7mk2') . '</i></p>'; } if ($_desc != '') { $output .= '<span class="of-metabox-desc">' . $_desc . '</span>' . "\n"; } $output .= '<div class="screenshot" id="' . $id . '-image">' . "\n"; if ($value != '') { $remove = '<a class="remove-image">Remove</a>'; $image = preg_match('/(^.*\\.jpg|jpeg|png|gif|ico*)/i', $value); if ($image) { $output .= '<img src="' . dt_get_of_uploaded_image($value) . '" alt="" />' . $remove; } else { $parts = explode("/", $value); for ($i = 0; $i < sizeof($parts); ++$i) { $title = $parts[$i]; } // No output preview if it's not an image. $output .= ''; // Standard generic output if it's not an image. $title = __('View File', 'the7mk2'); $output .= '<div class="no-image"><span class="file_link"><a href="' . $value . '" target="_blank" rel="external">' . $title . '</a></span></div>'; } } $output .= '</div>' . "\n"; return $output; }
/** * Returns device icons meta tags array. * * @since 2.2.1 * * @return array */ function presscore_get_device_icons() { $device_icons = array(array('option_id' => 'general-handheld_icon-old_iphone'), array('option_id' => 'general-handheld_icon-old_ipad', 'sizes' => '76x76'), array('option_id' => 'general-handheld_icon-retina_iphone', 'sizes' => '120x120'), array('option_id' => 'general-handheld_icon-retina_ipad', 'sizes' => '152x152')); $meta_tags = array(); foreach ($device_icons as $icon) { $src = dt_get_of_uploaded_image(of_get_option($icon['option_id'])); if ($src) { $meta_tags[] = '<link rel="apple-touch-icon"' . (empty($icon['sizes']) ? '' : ' sizes="' . esc_attr($icon['sizes']) . '"') . ' href="' . esc_url($src) . '">'; } } return $meta_tags; }
function optionsframework_medialibrary_uploader($_id, $_value, $_mode = 'full', $_desc = '', $_postid = 0, $_name = '') { $optionsframework_settings = get_option('optionsframework'); // Gets the unique option id $option_name = $optionsframework_settings['id']; $output = ''; $id = ''; $class = ''; $int = ''; $value = ''; $name = ''; $att_id = 0; $id = strip_tags(strtolower($_id)); // Change for each field, using a "silent" post. If no post is present, one will be created. $int = optionsframework_mlu_get_silentpost($id); // If a value is passed and we don't have a stored value, use the value that's passed through. if ($_mode == 'with_id') { $value = !empty($_value[0]) ? $_value[0] : ''; $att_id = !empty($_value[1]) ? intval($_value[1]) : 0; } elseif ($_value != '' && $value == '') { $value = $_value; } if ($_name != '') { $name = $option_name . '[' . $id . '][' . $_name . ']'; } else { $name = $option_name . '[' . $id . ']'; } if ($value) { $class = ' has-file'; } if ($_mode == 'with_id') { $output .= '<input id="' . $id . '" class="upload' . $class . '" type="text" name="' . $name . '[uri]" value="' . $value . '" />' . "\n"; $output .= '<input type="hidden" class="upload-id" name="' . $name . '[id]" value="' . $att_id . '" />' . "\n"; } else { $output .= '<input id="' . $id . '" class="upload' . $class . '" type="text" name="' . $name . '" value="' . $value . '" />' . "\n"; } $output .= '<input id="upload_' . $id . '" class="upload_button button" type="button" value="' . _x('Upload', 'backend', LANGUAGE_ZONE) . '" rel="' . $int . '" />' . "\n"; if ($_desc != '') { $output .= '<span class="of_metabox_desc">' . $_desc . '</span>' . "\n"; } $output .= '<div class="screenshot" id="' . $id . '_image">' . "\n"; if ($value != '') { $remove = '<a href="javascript:(void);" class="mlu_remove button">Remove</a>'; $image = preg_match('/(^.*\\.jpg|jpeg|png|gif|ico*)/i', $value); if ($image) { $value = dt_get_of_uploaded_image($value); $output .= '<img src="' . $value . '" alt="" />' . $remove . ''; } else { $parts = explode("/", $value); for ($i = 0; $i < sizeof($parts); ++$i) { $title = $parts[$i]; } // No output preview if it's not an image. $output .= ''; // Standard generic output if it's not an image. $title = _x('View File', 'backend', LANGUAGE_ZONE); $output .= '<div class="no_image"><span class="file_link"><a href="' . $value . '" target="_blank" rel="external">' . $title . '</a></span>' . $remove . '</div>'; } } $output .= '</div>' . "\n"; return $output; }