function gen_image_src($attachment_id, $width = false, $height = false, $crop = false) { // If user provide attachment url instead of attachment id if (filter_var($attachment_id, FILTER_VALIDATE_URL)) { $attachment_id = get_attachment_id_from_src($attachment_id); } // get the file path $file = get_attached_file($attachment_id); // validate attachment exist if ($file == '') { return ''; } // calculate and set width/height if one of width or height is false. if ($width == false xor $height == false) { $img = wp_get_attachment_image_src($attachment_id, 'full'); if ($img != false) { $img_ratio = $img[1] / $img[2]; if ($width == false) { $width = $height * $img_ratio; } else { if ($height == false) { $height = $width / $img_ratio; } } } } // build the resized filename $resize_extend = $width != false ? '-' . floor($width) : ''; $resize_extend .= $height != false ? 'x' . floor($height) : ''; $resize_extend .= $resize_extend != '' && $crop != false ? '-cropped' : ''; $resized_file = $cachefile = substr_replace($file, $resize_extend, strrpos($file, '.'), 0); // check the resized file existance $cache_exist = file_exists($resized_file); if (!$cache_exist) { $editor = wp_get_image_editor($file); $editor->resize($width, $height, $crop); $new_image_info = $editor->save($resized_file); $url = path_to_url($new_image_info['path']); } else { $url = path_to_url($resized_file); } return $url; }
function apply_cat($id) { global $wpdb; if (!is_numeric($id)) { echo 'insert numerc id'; return ''; } if (!(isset($_POST['parent']) && isset($_POST["ordering"]) && isset($_POST["name"]) && isset($_POST["content"]) && isset($_POST["param"]) && isset($_POST["ordering"]))) { echo 'not important values'; return ''; } $cat_row = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "spidercatalog_product_categories WHERE id!=%d ", $_GET['id'])); $corent_ord = $wpdb->get_var($wpdb->prepare('SELECT `ordering` FROM ' . $wpdb->prefix . 'spidercatalog_product_categories WHERE id=%d AND parent=%d', $id, $_POST['parent'])); $max_ord = $wpdb->get_var('SELECT MAX(ordering) FROM ' . $wpdb->prefix . 'spidercatalog_product_categories'); if ($corent_ord > $_POST["ordering"]) { $rows = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'spidercatalog_product_categories WHERE ordering>=%d AND id<>%d AND parent=%d ORDER BY `ordering` ASC ', $_POST["ordering"], $id, $_POST['parent'])); $count_of_rows = count($rows); $ordering_values = array(); $ordering_ids = array(); for ($i = 0; $i < $count_of_rows; $i++) { $ordering_ids[$i] = $rows[$i]->id; $ordering_values[$i] = $i + 1 + $_POST["ordering"]; } for ($i = 0; $i < $count_of_rows; $i++) { $wpdb->update($wpdb->prefix . 'spidercatalog_product_categories', array('ordering' => $ordering_values[$i]), array('id' => $ordering_ids[$i]), array('%d')); } } if ($corent_ord < $_POST["ordering"]) { $rows = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'spidercatalog_product_categories WHERE ordering<=%d AND id<>%d AND parent=%d ORDER BY `ordering` ASC ', $_POST["ordering"], $id, $_POST['parent'])); $count_of_rows = count($rows); $ordering_values = array(); $ordering_ids = array(); for ($i = 0; $i < $count_of_rows; $i++) { $ordering_ids[$i] = $rows[$i]->id; $ordering_values[$i] = $i + 1; } if ($max_ord == $_POST["ordering"] - 1) { $_POST["ordering"]--; } for ($i = 0; $i < $count_of_rows; $i++) { $wpdb->update($wpdb->prefix . 'spidercatalog_product_categories', array('ordering' => $ordering_values[$i]), array('id' => $ordering_ids[$i]), array('%d')); } } $query = $wpdb->prepare("SELECT parent FROM " . $wpdb->prefix . "spidercatalog_product_categories WHERE id=%d", $id); $id_bef = $wpdb->get_var($query); $images = explode(';;;', $_POST['uploadded_images_list']); $kk = count($images); for ($i = 0; $i < $kk; $i++) { $image_with_id = get_attachment_id_from_src($images[$i]); $images[$i] = $image_with_id; } $new_images = implode(';;;', $images); $script_cat = preg_replace('#<script(.*?)>(.*?)</script>#is', '', stripslashes($_POST["content"])); $savedd = $wpdb->update($wpdb->prefix . 'spidercatalog_product_categories', array('name' => esc_js($_POST["name"]), 'parent' => $_POST["parent"], 'category_image_url' => esc_js($new_images), 'description' => $script_cat, 'param' => esc_js($_POST["param"]), 'ordering' => $_POST["ordering"], 'published' => $_POST["published"]), array('id' => $id), array('%s', '%d', '%s', '%s', '%s', '%d', '%d')); if ($_POST["parent"] != 0) { $query = $wpdb->prepare("SELECT parent FROM " . $wpdb->prefix . "spidercatalog_product_categories WHERE id=%d", $id); $fff = $wpdb->get_var($query); $query = $wpdb->prepare("SELECT param FROM " . $wpdb->prefix . "spidercatalog_product_categories where id=%d", $fff); $rows1 = $wpdb->get_row($query); if (isset($_POST["parent"]) && $_POST["parent"] != $id_bef) { foreach ($rows1 as $par_cat) { $wpdb->update($wpdb->prefix . 'spidercatalog_product_categories', array('param' => $par_cat), array('id' => $id), array('%s')); } } } ?> <div class="updated"><p><strong><?php _e('Item Saved'); ?> </strong></p></div> <?php return true; }
</div> </div> <?php ?> <?php $rotator = new WP_Query('tag=mobile_main_rotating'); ?> <div class="main-image mobile"> <?php if ($rotator->have_posts()) { while ($rotator->have_posts()) { $rotator->the_post(); ?> <?php $image_url = get_post_meta(get_the_ID(), 'rotatimg-image-save', true); $attachment = get_post(get_attachment_id_from_src($image_url)); $test = get_post($image_url); // echo '<pre>'; print_r($test->post_excerpt); echo '</pre>' ?> <a href="<?php echo $test->post_excerpt; ?> " target="_blank"> <img src="<?php echo wp_get_attachment_url($image_url); ?> "> </a> <?php } }
function save_prad_cat() { global $wpdb; if (!(isset($_POST["ordering"]) && isset($_POST["uploadded_images_list"]) && isset($_POST["categ_search"]) && isset($_POST["content"]) && isset($_POST["param"]))) { echo 'cannot get \\$_POST[]'; exit; } if (isset($_POST["ordering"])) { $rows = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'spidercatalog_products WHERE ordering>=%d ORDER BY `ordering` ASC ', $_POST["ordering"])); } else { echo "<h1>Error</h1>"; return false; } $count_of_rows = count($rows); $ordering_values = array(); $ordering_ids = array(); for ($i = 0; $i < $count_of_rows; $i++) { $ordering_ids[$i] = $rows[$i]->id; $ordering_values[$i] = $i + 1 + $_POST["ordering"]; } for ($i = 0; $i < $count_of_rows; $i++) { $wpdb->update($wpdb->prefix . 'spidercatalog_products', array('ordering' => $ordering_values[$i]), array('id' => $ordering_ids[$i]), array('%d')); } $images = explode(';;;', $_POST['uploadded_images_list']); $kk = count($images); for ($i = 0; $i < $kk; $i++) { $image_with_id = get_attachment_id_from_src($images[$i]); $images[$i] = $image_with_id; } $new_images = implode(';;;', $images); $script_cat = preg_replace('#<script(.*?)>(.*?)</script>#is', '', stripslashes($_POST["content"])); $save_or_no = $wpdb->insert($wpdb->prefix . 'spidercatalog_products', array('id' => NULL, 'name' => esc_js($_POST['name']), 'category_id' => esc_js($_POST['categ_search']), 'description' => addslashes(htmlspecialchars(nl2br($script_cat))), 'image_url' => esc_js($new_images), 'cost' => esc_js(stripslashes($_POST['cost'])), 'market_cost' => esc_js($_POST['market_cost']), 'param' => esc_js($_POST['param']), 'ordering' => esc_js($_POST['ordering']), 'published' => $_POST['published'], 'published_in_parent' => $_POST['par_cat']), array('%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d')); if (!$save_or_no) { ?> <div class="updated"><p><strong><?php _e('Error. Please install plugin again'); ?> </strong></p></div> <?php return false; } ?> <div class="updated"><p><strong><?php _e('Item Saved'); ?> </strong></p></div> <?php return true; }
function be_themes_calculate_logo_width() { global $be_themes_data; $result = array(); $logo_src = !empty($be_themes_data['logo']['url']) ? $be_themes_data['logo']['url'] : get_template_directory_uri() . '/img/logo.png'; $logo_transparent_src = $be_themes_data['logo_transparent']['url']; if (array_key_exists('logo_transparent', $be_themes_data)) { $logo_transparent_src = $be_themes_data['logo_transparent']['url']; } if (empty($logo_transparent_src)) { $logo_transparent_src = $logo_src; } $logo_id = get_attachment_id_from_src($logo_src); $logo_transparent_id = get_attachment_id_from_src($logo_transparent_src); $logo = wp_get_attachment_image_src($logo_id, 'full'); $logo_transparent = wp_get_attachment_image_src($logo_transparent_id, 'full'); $logo_width = $logo_transparent_width = 250; if (isset($logo[1]) || !empty($logo[1])) { $logo_width = $logo[1]; } if (isset($logo_transparent[1]) || !empty($logo_transparent[1])) { $logo_transparent_width = $logo_transparent[1]; } $result['logo_width'] = $logo_width; $result['logo_transparent_width'] = $logo_transparent_width; return $result; }
function ag_slider($atts, $content = null) { extract(shortcode_atts(array('crop' => ''), $atts)); $crop = $crop ? ' ' . $crop : ''; global $slide_counter; $slide_counter++; $out = NULL; $out .= '<div class="clear"></div><div class="featured-image slidershortcode"><ul class="bxslider">'; $count = 1; $firstone = 1; foreach ($atts as $slide) { // Find Crop Variable while ($firstone == 1) { if ($slide == 'No' || $slide == 'no') { $crop = 'postnc'; } else { $crop = 'post'; } $firstone++; } // If not First One, get image Src and convert to correct thumbnail size if (!($slide == 'Yes' || $slide == 'yes' || $slide == 'no' || $slide == 'No')) { $image_id = get_attachment_id_from_src($slide); if ($image_id) { $caption = get_post($image_id)->post_excerpt; } else { $caption = ''; } $image_src = wp_get_attachment_image_src($image_id, $crop, false); if ($image_src) { $out .= '<li><img src="' . $image_src[0] . '" title="' . strip_tags(apply_filters('the_content', $caption)) . ' "/></li>'; } else { $out .= '<li><img src="' . $slide . '"/></li>'; } } $slide_counter++; $count++; } $out .= '</ul></div>'; return $out; }
} #logo{ margin-top: <?php echo $be_themes_data['logo_top_margin'] . 'px'; ?> ; margin-bottom: <?php echo $be_themes_data['logo_bottom_margin'] . 'px'; ?> ; } #navigation{ <?php $logo_id = get_attachment_id_from_src($be_themes_data['logo']); $logo = wp_get_attachment_image_src($logo_id, 'full'); $logo_height = 26; if (isset($logo[2]) || !empty($logo[2])) { $logo_height = $logo[2]; } $logo_height = $be_themes_data['logo_top_margin'] + $be_themes_data['logo_bottom_margin'] + $logo_height; ?> line-height: <?php echo $logo_height; ?> px; } #page-title h1{ margin-top: <?php
function remove_pdf($attachment_id) { $mime = get_post_mime_type($attachment_id); $options = get_option('pdf2img_settings'); $remove_pdf = $options['remove_pdf'] ? $options['remove_pdf'] : false; $image_url = wp_get_attachment_url($attachment_id, '') . "-0." . $options['img_extension']; if ($remove_pdf && $mime === "application/pdf") { wp_delete_attachment($attachment_id); $attachment_id = get_attachment_id_from_src($image_url); render_output($attachment_id); } return $attachment_id; }
" value="<?php $mb->the_value(); ?> "/></div> </div> </div> <div class="row"> <div class="cell file"> <label>Hover Image</label> <div class="input_container"> <?php $mb->the_field('involved_hover_image'); ?> <?php if ($mb->get_the_value() != '') { $thumb_array = wp_get_attachment_image_src(get_attachment_id_from_src($mb->get_the_value()), 'thumbnail'); $thumb = $thumb_array[0]; } else { $thumb = WP_PLUGIN_URL . '/msd-specialty-pages/lib/img/spacer.gif'; } ?> <img class="background-preview-img" src="<?php print $thumb; ?> "> <?php $group_name = 'involved_hover_img' . $mb->get_the_index(); ?> <?php $wpalchemy_media_access->setGroupName($group_name)->setInsertButtonLabel('Insert This')->setTab('gallery'); ?>
?> "><?php if (!empty($results->slideTitle)) { echo $results->slideTitle; } ?> </a></strong><br><div class="row-actions"><span class="edit"><a href="?page=wp_image_refresh_add&id=<?php echo $results->id_pk; ?> ">Edit</a></span></div></td> <td class="username column-username"> <strong><?php if (!empty($results->slideImage)) { $imgid = get_attachment_id_from_src($results->slideImage); if (!empty($imgid)) { echo wp_get_attachment_image($imgid, 'medium', false); } else { echo "<a><img width='300' src='" . $results->slideImage . "'>"; } } ?> </a></strong><br><div class="row-actions"><span class="edit"></span></div></td> </tr> <?php $i++; } } else { ?>
function ag_slider($atts, $content = null) { extract(shortcode_atts(array('crop' => ''), $atts)); $crop = $crop ? ' ' . $crop : ''; global $slide_counter; $slide_counter++; $out = NULL; $out .= '<div class="clear"></div><div class="slider-wrapper theme-default"><div class="slider nivoSlider">'; $count = 1; $firstone = 1; foreach ($atts as $slide) { // Find Crop Variable while ($firstone == 1) { if ($slide == 'No' || $slide == 'no') { $crop = 'postnc'; } else { $crop = 'post'; } $firstone++; } // If not First One, get image Src and convert to correct thumbnail size if (!($slide == 'Yes' || $slide == 'yes' || $slide == 'no' || $slide == 'No')) { $image_id = get_attachment_id_from_src($slide); $image_src = wp_get_attachment_image_src($image_id, $crop, false); if ($image_src) { $out .= '<img src="' . $image_src[0] . '"/>'; } else { $out .= '<img src="' . $slide . '"/>'; } } $slide_counter++; $count++; } $out .= '</div></div>'; return $out; }
/** * Function wc_slideshow. * Produces a slider from list of image URLs * Uses Nivo-Slider Scripts / Library * http://nivo.dev7studios.com/ * @slider_height (string) - height of the slider in px * @slider_width (string) - width of the slider in px * @effect (string) - use different effects * Returns timthumb URL. */ function wc_slideshow($atts, $content = null) { global $sa_general; extract(shortcode_atts(array('slider_height' => '0', 'slider_width' => '668', 'effect' => 'boxRandom', 'showtitle' => true), $atts)); $title = ''; $preStyle = ''; $IMG_TAGS = ''; $general_options = get_option('sa_general', $sa_general); $use_timthumb = $general_options['use_timthumb']; $slider_height_att = ''; if ($slider_height > 0) { $slider_height_att = "height:'" . $slider_height . "'"; } wp_print_scripts('jquery.nivo.slider'); $effect = strtolower($effect); /* Allows User to select their own slider effect. They pass this in with the effect=boxRain attribute. */ switch ($effect) { case 'slicedown': $effect = "sliceDown"; break; case 'sliceup': $effect = "sliceUp"; break; case 'sliceupdown': $effect = "sliceUpDown"; break; case 'fold': $effect = "fold"; break; case 'fade': $effect = "fade"; break; case 'boxrain': $effect = "boxRain"; break; default: $effect = "boxRandom"; } // Trim all space off $content. $content = trim($content); if ($content > "") { $doc = new DOMDocument(); $doc->loadHTML($content); $imageTags = $doc->getElementsByTagName('img'); //$imageHref = $doc->getElementsByTagName('a'); foreach ($imageTags as $tag) { // $content .= $tag->getAttribute('src') ."\n"; $IMG_TAGS .= $tag->getAttribute('src') . "\n"; } } // Remove all IMG TAGS $content = preg_replace("/<img[^>]+\\>/i", "", $content); // Remove all HREF TAGS $content = preg_replace("/<\\/?a(\\s+.*?>|>)/", "", $content); // ADD Everything together. $content = $content . "\n" . $IMG_TAGS; // Organize each line of content into an array. $images = !empty($content) ? preg_split("/(\r?\n)/", $content) : ''; //print_r($images); // Check if something exists and that it is an array. if (!empty($images) && is_array($images)) { // Clear the $content string. $content = ''; // For each image in the array, check for URL's and create the Nivo Slider Content. foreach ($images as $image) { // Strip any HTML Tags $image = trim(strip_tags($image)); // Separate the image path and link url (looks for comma to distinguish). $pos = strpos($image, ','); // Look for , and if it exists then we have to split URL and Image path. if ($pos === false) { $imagePath = $image; $imageLink = ''; } else { list($imagePath, $imageLink) = split(',', $image); } // Clean up any leading or trailing spaces. Make sure to remove http:// and https:// $imageLink = trim($imageLink); $imageLink = remove_http($imageLink); // If image path is no empty and it's great than nothing, continue... if (!empty($imagePath) && $imagePath > '') { // We now use get_attachment_id_from_src() to find the postID of the image attachement (custom function under /functions/common.php). $postid = get_attachment_id_from_src($imagePath); // Get the image size. $image_attributes = wp_get_attachment_image_src($postid, 'full'); // returns an array // Return the post object and title $postid = get_post($postid); if ($showtitle) { $title = $postid->post_title; } // Clear tmp vars. $imageLinkOpen = ""; $imageLinkClose = ""; // Build the tmp vars for the image link (if one was supplied) if ($imageLink > "") { $imageLinkOpen = "<a href='http://" . $imageLink . "'>"; $imageLinkClose = "</a>"; } // TIMTHUMB OPTION if ($use_timthumb) { // Build and add on to the $content string. $content .= $imageLinkOpen . "<img src='" . resize_img($image_attributes[0], $slider_width, $slider_height) . "' width='" . $slider_width . "' " . $slider_height_att . " alt='" . $title . "' title='" . $title . "' data-transition='" . $effect . "' />" . $imageLinkClose; } else { // DEFAULT RESIZING OPTION $content .= $imageLinkOpen . "<img src='" . $imagePath . "' width='" . $slider_width . "' " . $slider_height_att . " alt='" . $title . "' title='" . $title . "' data-transition='" . $effect . "' />" . $imageLinkClose; } } //end IF } // END FOR EACH $preHTML = "<div class=\"slider-wrapper theme-default\">\r\n\t\t\t\t\t<div class=\"ribbon\"></div>\r\n\t\t\t\t\t<div id=\"slider\" class=\"nivoSlider\" style=\"max-width:" . $slider_width . "px\">"; $postHTML = "</div>\n</div>"; return $preStyle . $preHTML . $content . $postHTML; } // END IF }
function show_metabox() { global $page_layout, $post, $meta_box; // Defines custom sidebar widget based on custom option $sidebarwidget = get_option('atp_customsidebar'); // Use nonce for verification echo '<input type="hidden" name="page_page_layout_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />'; // M E T A B O X W R A P //-------------------------------------------------------- echo '<div class="atp_meta_options">'; foreach ($this->_meta_box['fields'] as $field) { // get current post meta data $meta = get_post_meta($post->ID, $field['id'], true); if ($meta == "") { $meta = $field['std']; //Default Meta Array Value if empty } if (!isset($field['class'])) { $field['class'] = ''; } // M E T A B O X O P T I O N S //-------------------------------------------------------- echo '<div class="atp_options_box ' . $field['class'] . '"><div class="option-row">', '<div class="atp_label"><label>', $field['name'], '</label></div>', '<div class="atp_inputs">'; switch ($field['type']) { case 'text': echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" />'; break; case 'color': ?> <?php echo '<div class="meta_page_selectwrap"><input class="color" name="' . $field['id'] . '" id="' . $field['id'] . '" type="text" value="', $meta ? $meta : $field['std'], '" />'; ?> <div id="<?php echo $field['id']; ?> _color" class="wpcolorSelector"><div></div></div></div> <?php break; case 'textarea': echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>'; break; case 'select': echo '<div class="select_wrapper ', $field['class'], '"><select class="select" name="', $field['id'], '" id="', $field['id'], '">'; foreach ($field['options'] as $key => $value) { echo '<option value="' . $key . '"', $meta == $key ? ' selected="selected"' : '', '>', $value, '</option>'; } echo '</select></div>'; break; case 'multiselect': echo '<div class="select_wrapper2">'; $count = count($field['options']); if ($count > 0) { echo '<select multiple="multiple" name="', $field['id'], '[]" id="', $field['id'], '[]">'; foreach ($field['options'] as $key => $value) { echo '<option value="' . $key . '"', is_array($meta) && in_array($key, $meta) ? ' selected="selected"' : '', '>', $value, '</option>'; } echo '</select>'; } else { echo '<strong>No Posts IN Categories</strong>'; } echo '</div>'; break; case 'customselect': echo '<div class="select_wrapper ', $field['class'], '"><select class="select" name="', $field['id'], '" id="', $field['id'], '">'; echo '<option value="">select</option>'; if ($sidebarwidget != "") { foreach ($field['options'] as $key => $value) { echo '<option value="' . $value . '"', $meta == $value ? ' selected="selected"' : '', '>', $value, '</option>'; } } echo '</select></div>'; break; case 'newmeta': $output = '<div id="custom_widget_sidebar"><table id="custom_widget_table" cellpadding="0" cellspacing="0">'; $output .= '<tbody>'; if ($meta != "") { foreach ($meta as $custom_meta) { $output .= '<tr><td><input type="text" name="' . $field['id'] . '[]" value="' . esc_attr($custom_meta) . '" size="30" style="width:97%" /></td><td><a class="button button-secondary" href="javascript:void(0);return false;" onClick="jQuery(this).parent().parent().remove();">Delete</a></td></tr>'; } } $output .= '</tbody></table><button type="button" class="button button-primary button-large" name="add_custom_widget" value="Add Meta" onClick="addWidgetRow()">Add Meta</button></div>'; ?> <script type="text/javascript" language="javascript"> function addWidgetRow(){ jQuery('#custom_widget_table').append('<tr><td><input type="text" name="<?php echo $field['id']; ?> []" value="" size="30" style="width:97%" /></td><td><a class="button button-secondary" href="javascript:void(0);return false;" onClick="jQuery(this).parent().parent().remove();">Delete</a></td></tr>'); } </script> <?php echo $output; break; case 'timeslider': $timeslider_options = array('meta' => $meta, 'field_id' => $field['id']); echo apply_filters('timeslider', $timeslider_options); break; case 'map_location': $maplocation_options = array('meta' => $meta, 'field_id' => $field['id']); echo apply_filters('map_location', $maplocation_options); break; case 'add_buttons': $button_options = array('meta' => $meta, 'field_id' => $field['id']); echo apply_filters('add_buttons', $button_options); break; case 'external_mp3': $button_options = array('meta' => $meta, 'field_id' => $field['id']); echo apply_filters('add_externalmp3', $button_options); break; case 'radio': $link_page = ''; $link_cat = ''; $link_post = ''; $link_manually = ''; foreach ($field['options'] as $key => $value) { echo '<label class="rlabel"><input onclick="sys_custom_url_meta()" type="radio" name="', $field['id'], '" value="', $key, '"', $meta == $key ? ' checked="checked"' : '', ' />', $value, '</label>'; } global $post; $custom = get_post_custom($post->ID); if (isset($custom['link_page'])) { $link_page = $custom["link_page"][0]; } if (isset($custom['link_cat'])) { $link_cat = $custom["link_cat"][0]; } if (isset($custom['link_post'])) { $link_post = $custom["link_post"][0]; } if (isset($custom['link_manually'])) { $link_manually = stripslashes($custom["link_manually"][0]); } echo '<div id="customurl" >'; echo '<div id="sys_link" class="postlinkurl linkpage select_wrapper">'; echo '<select name="link_page" class="select">'; echo '<option value="">Select Page</option>'; foreach ($this->get_custom_options('page') as $key => $option) { echo '<option value="' . $key . '"'; if ($key == $link_page) { echo ' selected="selected"'; } echo '>' . $option . '</option>'; } echo '</select>'; echo '</div>'; echo '<div id="sys_category" class="postlinkurl linktocategory">'; echo '<select name="link_cat">'; echo '<option value="">Select Category</option>'; foreach ($this->get_custom_options('cat') as $key => $option) { echo '<option value="' . $key . '"'; if ($key == $link_cat) { echo ' selected="selected"'; } echo '>' . $option . '</option>'; } echo '</select>'; echo '</div>'; echo '<div id="sys_post" class="postlinkurl linktopost">'; echo '<select name="link_post">'; echo '<option value="">Select Post</option>'; foreach ($this->get_custom_options('post') as $key => $option) { echo '<option value="' . $key . '"'; if ($key == $link_post) { echo ' selected="selected"'; } echo '>' . $option . '</option>'; } echo '</select>'; echo '</div>'; echo '<div id="sys_manually" class="postlinkurl linkmanually">'; if (isset($link_manually)) { echo '<input type="text" name="link_manually" value="' . $link_manually . '" size="50%" />'; } else { echo '<input type="text" name="link_manually" value="" size="50%" />'; } echo '</div></div>'; break; case 'upload': echo '<input name="' . $field['id'] . '" id="' . $field['id'] . '" type="hidden" class="custom_upload_image" value="' . stripslashes(get_post_meta($post->ID, $field['id'], true)) . '" />'; echo '<input name="' . $field['id'] . '" id="' . $field['id'] . '" class="custom_upload_image_button button button-primary button-large clearfix" type="button" value="Choose Image" />'; echo '<div id="atp_imagepreview-' . $field['id'] . '" class="screenshot">'; if (get_post_meta($post->ID, $field['id'], true)) { $iva_img = get_post_meta($post->ID, $field['id'], true); $image_attributes = wp_get_attachment_image_src(get_attachment_id_from_src($iva_img)); if ($image_attributes[0] != '') { echo '<img src="' . $image_attributes[0] . '" class="custom_preview_image" alt="" />'; echo '<a href="#" class="cimage_remove button button-primary">x</a>'; } else { echo '<img src="' . $iva_img . '" class="custom_preview_image" alt="" />'; echo '<a href="#" class="cimage_remove button button-primary">x</a>'; } } echo '</div>'; break; case 'multiupload': // adjust values here $id = $field['id']; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == “img1” then $_POST[“img1”] will have all the image urls $multiimages = get_post_meta($post->ID, $id, true) ? get_post_meta($post->ID, $id, true) : ''; $svalue = $multiimages ? $multiimages : ''; // this will be initial value of the above form field. Image urls. $medialink = get_edit_post_link($post->ID); if ($field['multiple'] == 'true') { $multiple = true; } else { $multiple = false; } $format = $field['format'] ? $field['format'] : 'jpg,jpeg,gif,png'; $advance_meta = ''; $img_id = array(); $img_url = array(); $img_title = array(); $media_value = array(); $img_path = array(); $media_value = explode(',', $svalue); if ($media_value) { foreach ($media_value as $attachment_id) { $attachment = get_post($attachment_id); if (count($attachment) > 0) { $file_path = get_attached_file($attachment->ID, true); $upload_path = wp_get_attachment_url($attachment->ID, true); if (file_exists($file_path)) { if (preg_match_all('/[^\\?]+\\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $upload_path, $matches)) { $image_attributes = wp_get_attachment_image_src($attachment->ID, 'thumbnail'); // returns an array $uplaod_url = $image_attributes[0]; } else { $uplaod_url = $upload_path; } $img_url[] = get_edit_post_link($attachment->ID); $img_title[] = $attachment->post_title; $img_path[] = $uplaod_url; $img_id[] = $attachment->ID; } } } $img_title = join(', ', $img_title); $img_url = join(', ', $img_url); $img_path = join(', ', $img_path); $img_id = join(', ', $img_id); } $width = ''; // If you want to automatically resize all uploaded images then provide width here (in pixels) $height = ''; // If you want to automatically resize all uploaded images then provide height here (in pixels) ?> <input type="hidden" name="<?php echo $id; ?> " id="<?php echo $id; ?> " data-img="<?php echo $img_path; ?> " data-url="<?php echo $img_url; ?> " data-title="<?php echo $img_title; ?> " value="<?php echo $img_id; ?> " /> <input type="hidden" class="format_filter" value="<?php echo $format; ?> " /> <div class="plupload-upload-uic hide-if-no-js <?php if ($multiple) { ?> plupload-upload-uic-multiple<?php } ?> " id="<?php echo $id; ?> plupload-upload-ui"> <input id="<?php echo $id; ?> plupload-browse-button" type="button" value="<?php esc_attr_e('Select Files'); ?> " class="button" /> <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?> "></span> <?php if ($width && $height) { ?> <span class="plupload-resize"></span><span class="plupload-width" id="plupload-width<?php echo $width; ?> "></span> <span class="plupload-height" id="plupload-height<?php echo $height; ?> "></span> <?php } ?> <div class="filelist"></div> </div> <ul class="iva-images iva-uploaded plupload-thumbs <?php if ($multiple) { ?> plupload-thumbs-multiple<?php } ?> " id="<?php echo $id; ?> plupload-thumbs"></li> <div class="clear"></div> <?php break; case 'date': echo '<script type="text/javascript"> /* <![CDATA[ */ jQuery(document).ready(function() { jQuery("#' . $field['id'] . '").datepicker({ dateFormat: "d-MM-yy" }); }); /* ]]> */ </script>'; echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />'; break; case 'dateformat': global $default_date, $atp_defaultdate; echo '<script type="text/javascript"> /* <![CDATA[ */ jQuery(document).ready(function() { jQuery("#' . $field['id'] . '").datepicker({ dateFormat: "' . $atp_defaultdate . '" }); }); /* ]]> */ </script>'; $eventdate = get_post_meta($post->ID, $field['id'], true); if ($eventdate != '') { if (is_numeric($eventdate)) { $meta = date($default_date, get_post_meta($post->ID, $field['id'], true)); } else { $meta = $eventdate; $atp_defaultdate = 'd-MM-yy'; } } echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" />'; break; case 'layout': $i = 0; $select_value = $meta; foreach ($field['options'] as $key => $value) { $i++; $checked = ''; $selected = ''; if ($select_value != '') { if ($select_value == $key) { $checked = ' checked'; $selected = 'atp-radio-option-selected'; } } else { if ($meta == $key) { $checked = ' checked'; $selected = 'atp-radio-option-selected'; } elseif ($i == 1 && !isset($select_value)) { $checked = ' checked'; $selected = 'atp-radio-option-selected'; } elseif ($i == 1 && $meta == '') { $checked = ' checked'; $selected = 'atp-radio-option-selected'; } else { $checked = 'checked'; } } echo '<div class="layout"><input value="' . $key . '" class="checkbox atp-radio-img-radio" type="radio" id="', $field['id'], $i, '" name="', $field['id'], '"' . $checked . ' />'; echo '<img width="100" src="' . $value . '" alt="" class="atp-radio-option ' . $selected . '" onClick="document.getElementById(\'' . $field['id'] . $i . '\').checked = true;" /><span class="label">' . $key . '</span></div>'; } break; case 'checkbox': $meta != '' ? 'on' : 'off'; echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta == 'on' ? ' checked="checked"' : '', ' /><label for="', $field['id'], '">', $field['desc'], '</label>'; break; case 'background': $bg_image = $bg_color = $bg_repeat = $bg_position = $bg_attachement = ''; if (is_array($meta)) { if (!empty($meta)) { $bg_image = $meta['0']['image']; $bg_color = $meta['0']['color']; $bg_repeat = $meta['0']['repeat']; $bg_position = $meta['0']['position']; $bg_attachement = $meta['0']['attachement']; } } else { $bg_image = $meta; } // Position Properties Array $positionarray = array('left top' => 'Left Top', 'left center' => 'Left Center', 'left bottom' => 'Left Bottom', 'right top' => 'Right Top', 'right center' => 'Right Center', 'right bottom' => 'Right Bottom', 'center top' => 'Center Top', 'center center' => 'Center Center', 'center bottom' => 'Center Bottom'); // Repeat Properties Array $repeatarray = array('repeat' => 'Repeat', 'no-repeat' => 'No-Repeat', 'repeat-x' => 'Repeat-X', 'repeat-y' => 'Repeat-Y'); // Attachment Properties Array $attacharray = array('scroll' => 'Scroll', 'fixed' => 'Fixed'); echo '<div class="section section-background">'; //Upload Field echo '<div class="atp-background-upload clearfix">'; echo '<input type="text" name="' . $field['id'] . '_image" id="' . $field['id'] . '_image" class="custom_upload_image" value="' . $bg_image . '" />'; echo '<input type="button" name="' . $field['id'] . '_image" class="custom_upload_image_button button button-primary button-large" value="' . __('Choose Image', 'IVA_ADMIN_SITE') . '" />'; echo '<div class="clear"></div>'; echo '<div id="atp_imagepreview-' . $field['id'] . '_image" class="screenshot">'; if ($bg_image != '') { $image_attributes = wp_get_attachment_image_src(get_attachment_id_from_src($bg_image)); if ($image_attributes[0] != '') { echo '<img src="' . $image_attributes[0] . '" class="custom_preview_image" alt="" />'; echo '<a href="#" class="cimage_remove button button-primary">x</a>'; } else { echo '<img src="' . $bg_image . '" class="custom_preview_image" alt="" />'; echo '<a href="#" class="cimage_remove button button-primary">x</a>'; } } echo '</div></div>'; //Color Input echo '<div class="atp-background-color">'; echo '<input class="color" name="' . $field['id'] . '_color" id="' . $field['id'] . '_color" type="text" value="' . $bg_color . '">'; echo '<div id="' . $field['id'] . '_color" class="wpcolorSelector"><div></div></div>'; echo '</div>'; // Background Repeat Options Input echo '<div class="atp-background-repeat">'; echo '<div class="select_wrapper">'; echo '<select class="select" name="' . $field['id'] . '_repeat" id="' . $field['id'] . '_repeat">'; foreach ($repeatarray as $key => $value) { $selected = $key == $bg_repeat ? ' selected="selected"' : ''; echo '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>'; } echo '</select>'; echo '</div></div>'; //Background Position Options Input echo '<div class="atp-background-position"><div class="select_wrapper">'; echo '<select class="select" name="' . $field['id'] . '_position" id="' . $field['id'] . '_position">'; foreach ($positionarray as $key => $value) { $selected = $key == $bg_position ? ' selected="selected"' : ''; echo '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>'; } echo '</select>'; echo '</div></div>'; //Background Attachement Options Input echo '<div class="atp-background-attachment"><div class="select_wrapper">'; echo '<select class="select" name="' . $field['id'] . '_attachement" id="' . $field['id'] . '_attachement">'; foreach ($attacharray as $key => $value) { $selected = $key == $bg_attachement ? ' selected="selected"' : ''; echo '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>'; } echo '</select>'; echo '</div></div>'; echo '</div>'; break; } if ($field['type'] != 'checkbox') { echo '<p class="desc">', $field['desc'], '</p>'; } echo '</div><div class="clear"></div>'; echo '</div></div>'; } echo '</div>'; }
foreach ($sections as $section) { ?> <div class="section clear animate" data-type="<?php echo $section['section_type'][1]; ?> "> <h6><? echo $section['section_title'][1]; ?></h6> <?php if ($section['section_type'][1] == 'Design Comps' || $section['section_type'][1] == 'Demo Path') { ?> <div class="gallery"> <?php foreach ($section['section_media_file'] as $media) { //Grab the image assets $image_id = get_attachment_id_from_src($media['original']); $img_array = wp_get_attachment($image_id); $thumb = wp_get_attachment_image($image_id, 'thumbnail'); $dataClass = $img_array['description']; if ($section['section_type'][1] == 'Demo Path') { $dataClass = "demo"; } echo '<a href="' . $img_array['src'] . '" class="left thumbs" data-class="' . $dataClass . '">' . $thumb . '<br />' . $img_array['title'] . '</a>'; } ?> </div><!-- end gallery --> <?php } else { echo $section['section_asset_list'][1]; } ?>
function loadslider($atts) { global $wpdb; $atts = shortcode_atts(array('type' => 'full', 'class' => '', 'title' => false, 'container' => '', 'container_class' => '', 'title_container' => '', 'title_container_class' => ''), $atts, 'wp-image-refresh'); $table_name = $wpdb->prefix . "image_refresh"; if (count($_SESSION['slideimageall']) == 0) { $images = $wpdb->get_results("SELECT slideTitle,slideImage,slideText FROM {$table_name} ORDER BY rand()", OBJECT); //Hold complete Image array $_SESSION['slideimageall'] = array(); foreach ($images as $images1) { array_push($_SESSION['slideimageall'], array('slideImage' => $images1->slideImage, 'slideTitle' => $images1->slideTitle, 'slideText' => $images1->slideText)); } } //Check if slide images are available otherwise copy from main array if (!empty($_SESSION['slideimage']) && is_array($_SESSION['slideimage'])) { $myarr = array_pop($_SESSION['slideimage']); } elseif (!empty($_SESSION['slideimageall']) && is_array($_SESSION['slideimageall'])) { $_SESSION['slideimage'] = $_SESSION['slideimageall']; shuffle($_SESSION['slideimage']); $myarr = array_pop($_SESSION['slideimage']); } else { echo "Error occurred when extracting header image"; return; } if (!empty($myarr) && is_array($myarr)) { $imgid = get_attachment_id_from_src($myarr['slideImage']); if (!empty($imgid)) { $myarr['st'] = 1; $myarr['slideImage'] = wp_get_attachment_image($imgid, $atts['type'], false, array('class' => $atts['class'], 'alt' => $myarr['slideTitle'])); } else { $myarr['st'] = 2; } $imgs_src = ''; $imgs_title = ''; if (!empty($myarr['slideImage'])) { $imgs_src = $myarr['slideImage']; } if (!empty($myarr['slideText'])) { $slideText = $myarr['slideText']; } if (!empty($myarr['slideTitle'])) { $imgs_title = $myarr['slideTitle']; } if ($myarr['st'] == 2) { $outimg = '<img class="' . $atts['class'] . '" src="' . $imgs_src . '" alt="' . $imgs_title . '">'; } else { $outimg = $myarr['slideImage']; //getCont($atts['container'] , $atts['container_class'] , $outimg); } if ($atts['title'] == 'true') { getCont($atts['container'], $atts['container_class'], $outimg, $atts['title_container'], $atts['title_container_class'], $myarr['slideTitle'], $slideText); } else { getCont($atts['container'], $atts['container_class'], $outimg, '', '', '', $slideText); } } else { echo 'Error occurred when extracting header image '; } }
<div class="post-item copy"> <div class="post-img"> <a href="<?php the_permalink(); ?> "> <?php if (get_the_post_thumbnail()) { ?> <img src="<?php echo $single_post_img; ?> " alt="" class='img-center'> <?php } else { $no_img = wp_get_attachment_image_src(get_attachment_id_from_src(of_get_option('no_image', '')), 'thumbnail'); $no_img = $no_img[0]; ?> <img src="<?php echo $no_img; ?> " alt=""> <?php } ?> </a> </div> <div class="post-title"><h4 class="t-title t-sm2 mb-10"><a href="<?php the_permalink(); ?>
function optionsframework_medialibrary_uploader($_id, $_value, $_mode = 'full', $_desc = '', $_postid = 0, $_name = '') { /* earlier code $optionsframework_settings = get_option($_id); //print_r($optionsframework_settings); // Gets the unique option id $option_name = $optionsframework_settings['id']; */ /* new code*/ $option_name = get_option($_id); /* end new code */ $output = $id = $class = $int = $name = ''; $value = get_option($_id); $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 ($_value != '' && $value == '') { $value = $_value; } if ($_name != '') { $name = $option_name . '[' . $id . '][' . $_name . ']'; } else { $name = $option_name . '[' . $id . ']'; } if ($value) { $class = ' has-file'; } $output .= '<input id="' . $id . '" class="upload' . $class . '" type="text" name="' . $id . '" value="' . $value . '" />' . "\n"; $output .= '<input id="upload_' . $id . '" class="upload_button button-primary button-large" type="button" value="' . __('Upload', 'optionsframework') . '" rel="' . $int . '" />' . "\n"; if ($_desc != '') { $output .= '<span class="of_metabox_desc">' . $_desc . '</span>' . "\n"; } $output .= '<div class="clear"></div><div class="screenshot" id="' . $id . '_image">' . "\n"; if ($value != '') { $remove = '<a href="javascript:(void);" class="custom_clear_image_button button button-primary">x</a>'; $image = preg_match('/(^.*\\.jpg|jpeg|png|gif*)/i', $value); if ($image) { $image_attributes = wp_get_attachment_image_src(get_attachment_id_from_src($value)); if ($image_attributes[0] != '') { $output .= '<img src="' . $image_attributes[0] . '" alt="" />' . $remove . ''; } else { $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 = __('View File', 'optionsframework'); $output .= '<div class="no_image"><span class="file_link"></span>' . $remove . '</div>'; } } $output .= '</div>' . "\n"; return $output; }
function county_slider_shortcode_handler() { $counties = $this->get_all_counties(); foreach ($counties as $county) { ${$county->state}[] = $county; } $counties = array_merge($Kentucky, $Indiana); //the header $old_state = $hdr = ''; $i = 0; foreach ($counties as $county) { $state = $county->state; $active = $i == 0 ? ' active' : ''; $state_str = $state != $old_state ? '<span class="state ' . strtolower($state) . '">' . $this->swap_state_name_abrv($state) . ': </span>' : ''; $title_short = preg_replace('/\\sCounty/i', '', $county->post_title); $hdr .= '<li class="item-nav' . $active . '" data-target="#counties" data-slide-to="' . $i . '">' . $state_str . '<span class="county">' . $title_short . '</span></li>'; $old_state = $state; $i++; } $hdr = '<ol class="carousel-indicators">' . $hdr . '</ol>'; //the body $body = ''; $i = 0; foreach ($counties as $county) { $active = $i == 0 ? ' active' : ''; $image_id = $county->bio_image_cropped != '' ? get_attachment_id_from_src($county->bio_image_cropped) : get_attachment_id_from_src($county->bio_image); $image = wp_get_attachment_image($image_id, 'thumbnail'); $insecure_individuals = strlen($county->insecure_individuals) > 0 ? $county->insecure_individuals : '____'; $bio_name = strlen($county->bio_name) > 0 ? $county->bio_name : '____'; $pounds_food = strlen($county->pounds_food) > 0 ? $county->pounds_food : '____'; $data_year = strlen($county->data_year) > 0 ? $county->data_year : '____'; $body .= ' <div class="item' . $active . '"> <div class="titles"> <h2><a href="' . get_post_permalink($county->ID) . '">Hunger in ' . $county->post_title . '</a></h2> </div> <div class="row"> <a href="' . get_post_permalink($county->ID) . '" class="col-sm-4 people"> <div class="icon icon-people"></div> <strong>' . $insecure_individuals . '</strong> people who lack the food to live a healthy life </a> <div class="col-sm-4 bio"> <a href="' . get_post_permalink($county->ID) . '#bio"> ' . $image . ' <strong>Meet</strong> ' . $bio_name . ' </a> </div> <a href="' . get_post_permalink($county->ID) . '"class="col-sm-4 veggies"> <div class="icon icon-veggies"></div> <strong>' . $pounds_food . '</strong> pounds of free food distributed to those in need in ' . $data_year . ' </a> </div> </div>'; $i++; } $ret = '<div id="counties" class="carousel slide" data-interval="0" data-ride="carousel"> ' . $hdr . ' <div class="carousel-inner" role="listbox"> ' . $body . ' </div> </div> <script> jQuery(document).ready(function($) { $(".counties").carousel({ interval: 0 }) }); </script>'; return $ret; }