当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_basename函数代码示例

本文整理汇总了PHP中wp_basename函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_basename函数的具体用法?PHP wp_basename怎么用?PHP wp_basename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_basename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: surbma_divi_gravity_forms_enqueue_scripts

function surbma_divi_gravity_forms_enqueue_scripts()
{
    if (wp_basename(get_bloginfo('template_directory')) == 'Divi' && class_exists('GFForms')) {
        wp_enqueue_style('surbma-divi-gravity-forms-styles', plugins_url('', __FILE__) . '/css/surbma-divi-gravity-forms.css');
        $accent_color = esc_html(et_get_option('accent_color', '#2ea3f2'));
        $all_buttons_font_size = esc_html(et_get_option('all_buttons_font_size', '20'));
        $all_buttons_text_color = esc_html(et_get_option('all_buttons_text_color', $accent_color));
        $all_buttons_text_color_hover = esc_html(et_get_option('all_buttons_text_color_hover', $accent_color));
        $all_buttons_bg_color = esc_html(et_get_option('all_buttons_bg_color', '#fff'));
        $all_buttons_bg_color_hover = esc_html(et_get_option('all_buttons_bg_color_hover', 'rgba(0,0,0,.05)'));
        $all_buttons_border_width = esc_html(et_get_option('all_buttons_border_width', '2'));
        $all_buttons_border_color = esc_html(et_get_option('all_buttons_border_color', $accent_color));
        $all_buttons_border_color_hover = esc_html(et_get_option('all_buttons_border_color_hover', 'transparent'));
        $all_buttons_border_radius = esc_html(et_get_option('all_buttons_border_radius', '3'));
        $all_buttons_border_radius_hover = esc_html(et_get_option('all_buttons_border_radius_hover', '3'));
        $all_buttons_spacing = esc_html(et_get_option('all_buttons_spacing', '0'));
        $all_buttons_spacing_hover = esc_html(et_get_option('all_buttons_spacing_hover', '0'));
        $all_buttons_font_style = esc_html(et_get_option('all_buttons_font_style', '', '', true));
        $button_text_style = '';
        if ($all_buttons_font_style !== '') {
            $button_text_style = et_pb_print_font_style($all_buttons_font_style);
        }
        $all_buttons_font = esc_html(et_get_option('all_buttons_font', 'inherit'));
        $custom_css = "body .gform_wrapper .gform_footer input.button,body .gform_wrapper .gform_page_footer input.button{background-color:{$all_buttons_bg_color};color:{$accent_color};border-width:{$all_buttons_border_width}px;border-color:{$all_buttons_border_color};border-radius:{$all_buttons_border_radius}px;font-family:{$all_buttons_font};font-size:{$all_buttons_font_size}px;letter-spacing:{$all_buttons_spacing}px;{$button_text_style}}body .gform_wrapper .gform_footer input.button:hover,body .gform_wrapper .gform_page_footer input.button:hover{background-color:{$all_buttons_bg_color_hover};color:{$all_buttons_text_color_hover};border-color:{$all_buttons_border_color_hover};border-radius:{$all_buttons_border_radius_hover}px;letter-spacing:{$all_buttons_spacing_hover}px;}}";
        wp_add_inline_style('surbma-divi-gravity-forms-styles', $custom_css);
    }
}
开发者ID:planetahuevo,项目名称:surbma-divi-gravity-forms,代码行数:27,代码来源:surbma-divi-gravity-forms.php

示例2: prepare_post

 /**
  * Get attachment-specific data
  *
  * @param array $post
  * @return array
  */
 protected function prepare_post($post, $context = 'single')
 {
     $data = parent::prepare_post($post, $context);
     if (is_wp_error($data) || $post['post_type'] !== 'attachment') {
         return $data;
     }
     // $thumbnail_size = current_theme_supports( 'post-thumbnail' ) ? 'post-thumbnail' : 'thumbnail';
     $data['source'] = wp_get_attachment_url($post['ID']);
     $data['is_image'] = wp_attachment_is_image($post['ID']);
     $data['attachment_meta'] = wp_get_attachment_metadata($post['ID']);
     // Ensure empty meta is an empty object
     if (empty($data['attachment_meta'])) {
         $data['attachment_meta'] = new stdClass();
     } elseif (!empty($data['attachment_meta']['sizes'])) {
         $img_url_basename = wp_basename($data['source']);
         foreach ($data['attachment_meta']['sizes'] as $size => &$size_data) {
             // Use the same method image_downsize() does
             $size_data['url'] = str_replace($img_url_basename, $size_data['file'], $data['source']);
         }
     } else {
         $data['attachment_meta']['sizes'] = new stdClass();
     }
     // Override entity meta keys with the correct links
     $data['meta'] = array('links' => array('self' => json_url('/media/' . $post['ID']), 'author' => json_url('/users/' . $post['post_author']), 'collection' => json_url('/media'), 'replies' => json_url('/media/' . $post['ID'] . '/comments'), 'version-history' => json_url('/media/' . $post['ID'] . '/revisions')));
     if (!empty($post['post_parent'])) {
         $data['meta']['links']['up'] = json_url('/media/' . (int) $post['post_parent']);
     }
     return apply_filters('json_prepare_attachment', $data, $post, $context);
 }
开发者ID:dani-ocean,项目名称:wp_angular_api,代码行数:35,代码来源:class-wp-json-media.php

示例3: create_photo_item_by_id

 function create_photo_item_by_id($image_id)
 {
     $this->id = $image_id;
     $image_post = get_post($image_id);
     $this->name = $image_post->post_title;
     $this->description = $image_post->post_content;
     $this->date_uploaded = $image_post->post_date;
     $this->alt_text = get_post_meta($image_id, '_wp_attachment_image_alt', true);
     if (empty($this->alt_text)) {
         //if the alt text meta is blank, let's set it to the image name
         $this->alt_text = $image_post->post_name;
     }
     $this->gallery_id = get_post_meta($image_id, '_wppg_gallery_id', true);
     $upload_dir = wp_upload_dir();
     $this->source_dir = $upload_dir['basedir'] . '/' . WPPG_UPLOAD_SUB_DIRNAME . '/' . $this->gallery_id . '/';
     $this->source_dir_url = $upload_dir['baseurl'] . '/' . WPPG_UPLOAD_SUB_DIRNAME . '/' . $this->gallery_id . '/';
     $image_attributes = wp_get_attachment_image_src($image_id, 'full');
     // get full sized image - returns an array
     if ($image_attributes) {
         $this->image_file_url = $image_attributes[0];
         //get the image URL
     } else {
         $this->image_file_url = $image_post->guid;
         //NOTE: use guid as absolute last resort because it is not an accurate indication of image URL
     }
     $this->thumb_url = wp_get_attachment_thumb_url($image_id);
     $this->image_file_name = esc_html(wp_basename($this->image_file_url));
     $this->image_file_path = $this->source_dir . $this->image_file_name;
     $attachment_img_src_data = get_post_meta($image_id, '_wp_attachment_metadata', true);
     $this->image_width = $attachment_img_src_data['width'];
     $this->image_height = $attachment_img_src_data['height'];
 }
开发者ID:acamboy,项目名称:kutetheme-wp,代码行数:32,代码来源:wppg-photo-gallery-item-class.php

示例4: cycloneslider_thumb

function cycloneslider_thumb($original_attachment_id, $width, $height, $refresh = false, $slide_meta = array())
{
    $dir = wp_upload_dir();
    // Get full path to the slide image
    $image_path = get_attached_file($original_attachment_id);
    $image_path = apply_filters('cycloneslider_image_path', $image_path, $slide_meta);
    if (empty($image_path)) {
        return false;
    }
    // Full url to the slide image
    $image_url = wp_get_attachment_url($original_attachment_id);
    $image_url = apply_filters('cycloneslider_image_url', $image_url, $slide_meta);
    if (empty($image_url)) {
        return false;
    }
    $info = pathinfo($image_path);
    $dirname = isset($info['dirname']) ? $info['dirname'] : '';
    // Path to directory
    $ext = isset($info['extension']) ? $info['extension'] : '';
    // File extension Eg. "jpg"
    $thumb = wp_basename($image_path, ".{$ext}") . "-{$width}x{$height}.{$ext}";
    // Thumbname. Eg. [imagename]-[width]x[height].hpg
    // Check if thumb already exists. If it is, return its url, unless refresh is true
    if (file_exists($dirname . '/' . $thumb) and !$refresh) {
        return dirname($image_url) . '/' . $thumb;
        //We used dirname() since we need the URL format not the path
    }
    $resizeObj = new Image_Resizer($image_path);
    $resizeObj->resizeImage($width, $height);
    $resizeObj->saveImage($dirname . '/' . $thumb, 80);
    return dirname($image_url) . '/' . $thumb;
}
开发者ID:joffcrabtree,项目名称:wp-cyclone-slider,代码行数:32,代码来源:cyclone-slider.php

示例5: getImage

 public function getImage($id)
 {
     $image_fields = array("ID" => "ID", "guid" => "file", "post_mime_type" => "mime_type");
     $indexable_image_size = get_intermediate_image_sizes();
     $uploadDir = wp_upload_dir();
     $uploadBaseUrl = $uploadDir['baseurl'];
     $image = new \stdClass();
     $post = get_post($id);
     foreach ($image_fields as $key => $value) {
         $image->{$value} = $post->{$key};
     }
     $metas = get_post_meta($post->ID, '_wp_attachment_metadata', true);
     $image->width = $metas["width"];
     $image->height = $metas["height"];
     $image->file = sprintf('%s/%s', $uploadBaseUrl, $metas["file"]);
     $image->sizes = $metas["sizes"] ? $metas["sizes"] : array();
     foreach ($image->sizes as $size => &$sizeAttrs) {
         if (in_array($size, $indexable_image_size) == false) {
             unset($image->sizes[$size]);
             continue;
         }
         $baseFileUrl = str_replace(wp_basename($metas['file']), '', $metas['file']);
         $sizeAttrs['file'] = sprintf('%s/%s%s', $uploadBaseUrl, $baseFileUrl, $sizeAttrs['file']);
     }
     return $image;
 }
开发者ID:PoNote,项目名称:algoliasearch-wordpress,代码行数:26,代码来源:WordpressFetcher.php

示例6: wp_generate_attachment_metadata

 public function wp_generate_attachment_metadata($metadata, $attachment_id)
 {
     $attachment = get_attached_file($attachment_id);
     if (!preg_match('!^image/!', get_post_mime_type($attachment_id)) || !file_is_displayable_image($attachment)) {
         return $metadata;
     }
     $image_sizes = Helper::get_image_sizes();
     foreach ($image_sizes as $size_name => $size_attributes) {
         if (!empty($metadata['sizes'][$size_name])) {
             continue;
         }
         $image = wp_get_image_editor($attachment);
         if (is_wp_error($image)) {
             continue;
         }
         $resized = $image->resize($size_attributes['width'], $size_attributes['height'], $size_attributes['crop']);
         $image_size = $image->get_size();
         if (!is_wp_error($resized) && !empty($image_size)) {
             $filename = wp_basename($image->generate_filename());
             $extension = pathinfo($filename, PATHINFO_EXTENSION);
             $mime_type = $this->get_mime_type($extension);
             $metadata['sizes'][$size_name] = array('file' => $filename, 'width' => $image_size['width'], 'height' => $image_size['height'], 'mime-type' => $mime_type);
         }
     }
     return $metadata;
 }
开发者ID:brutalenemy666,项目名称:carbon-image-library,代码行数:26,代码来源:WP_Media.php

示例7: groundup_image_suffix

 function groundup_image_suffix($image)
 {
     // Split the $image path into directory/extension/name
     $info = pathinfo($image);
     $dir = $info['dirname'] . '/';
     $ext = '.' . $info['extension'];
     $file_name = wp_basename($image, "{$ext}");
     $image_name = substr($file_name, 0, strrpos($file_name, '-'));
     // Get image information
     $img = wp_get_image_editor($image);
     // Get image size, width and height
     $img_size = $img->get_size();
     // Get new image suffix by comparing image sizes
     $image_sizes = get_intermediate_image_sizes();
     foreach ($image_sizes as $size) {
         $rename = false;
         $sizeInfo = get_image_size_data($size);
         if ($img_size['width'] == $sizeInfo['width'] && $img_size['height'] <= $sizeInfo['height']) {
             $rename = true;
         } elseif ($img_size['height'] == $sizeInfo['height'] && $img_size['width'] <= $sizeInfo['width']) {
             $rename = true;
         }
         if ($rename == true) {
             // Rename image
             $new_name = $dir . $image_name . '-' . $size . $ext;
             // Rename the intermediate size
             $rename_success = rename($image, $new_name);
             if ($rename_success) {
                 return $new_name;
             }
         }
     }
     // do nothing if not renamed
     return $image;
 }
开发者ID:abacusadvertising,项目名称:groundup,代码行数:35,代码来源:admin.php

示例8: replace_uploaded_image

function replace_uploaded_image($image_data)
{
    // if there is no large image : return
    if (!isset($image_data['sizes']['huge'])) {
        return $image_data;
    }
    // paths to the uploaded image and the large image
    $upload_dir = wp_upload_dir();
    $uploaded_image_location = $upload_dir['basedir'] . '/' . $image_data['file'];
    $large_image_filename = $image_data['sizes']['huge']['file'];
    // Do what wordpress does in image_downsize() ... just replace the filenames ;)
    $image_basename = wp_basename($uploaded_image_location);
    $large_image_location = str_replace($image_basename, $large_image_filename, $uploaded_image_location);
    // delete the uploaded image
    unlink($uploaded_image_location);
    // rename the large image
    rename($large_image_location, $uploaded_image_location);
    // update image metadata and return them
    $image_data['width'] = $image_data['sizes']['huge']['width'];
    $image_data['height'] = $image_data['sizes']['huge']['height'];
    unset($image_data['sizes']['huge']);
    // Check if other size-configurations link to the large-file
    foreach ($image_data['sizes'] as $size => $sizeData) {
        if ($sizeData['file'] === $large_image_filename) {
            unset($image_data['sizes'][$size]);
        }
    }
    return $image_data;
}
开发者ID:piojos,项目名称:quadra,代码行数:29,代码来源:functions.php

示例9: downsize

 function downsize($out, $id, $size)
 {
     $img_url = wp_get_attachment_url($id);
     $img_path = get_attached_file($id);
     $meta = wp_get_attachment_metadata($id);
     $width = $height = 0;
     $is_intermediate = false;
     $img_url_basename = wp_basename($img_url);
     $img_path_basename = wp_basename($img_path);
     // extract filter from size request
     if (!is_string($size)) {
         return $out;
     }
     $size_bits = explode(':', $size);
     $filter = isset($size_bits[1]) ? $size_bits[1] : false;
     $size = isset($size_bits[0]) ? $size_bits[0] : false;
     // start the reactor
     if ($filter) {
         // try for a new style intermediate size
         if ($intermediate = image_get_intermediate_size($id, $size)) {
             $img_url = str_replace($img_url_basename, $intermediate['file'], $img_url);
             $img_path = str_replace($img_path_basename, $intermediate['file'], $img_path);
             $width = $intermediate['width'];
             $height = $intermediate['height'];
             $is_intermediate = true;
         } elseif ($size == 'thumbnail') {
             // fall back to the old thumbnail
             if (($thumb_file = wp_get_attachment_thumb_file($id)) && ($info = getimagesize($thumb_file))) {
                 $img_url = str_replace($img_url_basename, wp_basename($thumb_file), $img_url);
                 $img_path = str_replace($img_path_basename, wp_basename($thumb_file), $img_path);
                 $width = $info[0];
                 $height = $info[1];
                 $is_intermediate = true;
             }
         }
         if (!$width && !$height && isset($meta['width'], $meta['height'])) {
             // any other type: use the real image
             $width = $meta['width'];
             $height = $meta['height'];
         }
         if ($img_url && $img_path) {
             $input = $img_path;
             $output = $this->filtered_url($input, $filter);
             // generate filtered thumb
             if (!file_exists($output)) {
                 $this->filter($filter, $input, $output);
             }
             // point to our new file
             $img_url = $this->filtered_url($img_url, $filter);
             // we have the actual image size, but might need to further constrain it if content_width is narrower
             list($width, $height) = image_constrain_size_for_editor($width, $height, $size);
             return array($img_url, $width, $height, $is_intermediate);
         }
         // don't continue the downsize funtion
         return true;
     }
     return $out;
 }
开发者ID:netconstructor,项目名称:wp-instagraph,代码行数:58,代码来源:wp-instagraph.php

示例10: process

 public function process($attachment, $width, $height, $crop = false)
 {
     $attachment_info = $this->get_attachment_info($attachment);
     if (!$attachment_info) {
         return new WP_Error('invalid_attachment', 'Invalid Attachment', $attachment);
     }
     $file_path = $attachment_info['path'];
     $info = pathinfo($file_path);
     $dir = $info['dirname'];
     $ext = isset($info['extension']) ? $info['extension'] : 'jpg';
     $name = wp_basename($file_path, ".{$ext}");
     $name = preg_replace('/(.+)(\\-\\d+x\\d+)$/', '$1', $name);
     // Suffix applied to filename
     $suffix = "{$width}x{$height}";
     // Get the destination file name
     $destination_file_name = "{$dir}/{$name}-{$suffix}.{$ext}";
     // No need to resize & create a new image if it already exists
     if (!file_exists($destination_file_name)) {
         //Image Resize
         $editor = wp_get_image_editor($file_path);
         if (is_wp_error($editor)) {
             return new WP_Error('wp_image_editor', 'WP Image editor can\'t resize this attachment', $attachment);
         }
         // Get the original image size
         $size = $editor->get_size();
         $orig_width = $size['width'];
         $orig_height = $size['height'];
         $src_x = $src_y = 0;
         $src_w = $orig_width;
         $src_h = $orig_height;
         if ($crop) {
             $cmp_x = $orig_width / $width;
             $cmp_y = $orig_height / $height;
             // Calculate x or y coordinate, and width or height of source
             if ($cmp_x > $cmp_y) {
                 $src_w = round($orig_width / $cmp_x * $cmp_y);
                 $src_x = round(($orig_width - $orig_width / $cmp_x * $cmp_y) / 2);
             } else {
                 if ($cmp_y > $cmp_x) {
                     $src_h = round($orig_height / $cmp_y * $cmp_x);
                     $src_y = round(($orig_height - $orig_height / $cmp_y * $cmp_x) / 2);
                 }
             }
         }
         $editor->crop($src_x, $src_y, $src_w, $src_h, $width, $height);
         $saved = $editor->save($destination_file_name);
         $images = wp_get_attachment_metadata($attachment_info['id']);
         if (!empty($images['resizes']) && is_array($images['resizes'])) {
             foreach ($images['resizes'] as $image_size => $image_path) {
                 $images['resizes'][$image_size] = addslashes($image_path);
             }
         }
         $uploads_dir = wp_upload_dir();
         $images['resizes'][$suffix] = $uploads_dir['subdir'] . '/' . $saved['file'];
         wp_update_attachment_metadata($attachment_info['id'], $images);
     }
     return array('id' => $attachment_info['id'], 'src' => str_replace(basename($attachment_info['url']), basename($destination_file_name), $attachment_info['url']));
 }
开发者ID:floq-design,项目名称:Unyson,代码行数:58,代码来源:class-fw-resize.php

示例11: __construct

 /**
  * This hook is called once any activated themes have been loaded.
  */
 protected function __construct($settings = array())
 {
     $theme = get_file_data(get_stylesheet_directory() . '/style.css', array('name' => 'Theme Name', 'version' => 'Version', 'text_domain' => 'Text domain'), 'theme');
     $this->version = $theme['version'];
     $this->name_raw = $theme['name'];
     $this->name = wp_basename(get_stylesheet_directory());
     $this->uri = get_stylesheet_directory_uri();
     $this->path = get_stylesheet_directory();
     $this->text_domain = $theme['text_domain'];
     $this->domain_path = get_template_directory() . '/languages';
 }
开发者ID:visualive,项目名称:vavg,代码行数:14,代码来源:class-theme-define.php

示例12: get

 /**
  * Returns the type for the post, the term template applies to what type of
  * post is or what type of template is using.
  *
  * @param Int|\WP_Post $post The post
  * @return string
  */
 public static function get($post)
 {
     $post = is_a($post, 'WP_Post') ? $post : get_post($post);
     $type = $post->post_type;
     if ('page' === $type) {
         $template_slug = get_page_template_slug($post->ID);
         if (!empty($template_slug)) {
             $type .= '-' . wp_basename($template_slug, '.php');
         }
     }
     return $type;
 }
开发者ID:moxie-leean,项目名称:wp-endpoints-post,代码行数:19,代码来源:Type.php

示例13: hook_javascript

function hook_javascript()
{
    global $url;
    //echo "<meta name='viewport' content='width=device-width, initial-scale=1'>"."\r\n";
    foreach (glob(plugin_dir_path(__FILE__) . "lib/js/*.js") as $file) {
        $url = plugins_url(wp_basename($file), "/kaltst/lib/js/*.js");
        echo "<script type='text/javascript' src='" . $url . "'></script>" . "\r\n";
    }
    foreach (glob(plugin_dir_path(__FILE__) . "lib/css/*.css") as $csss) {
        $url = plugins_url(wp_basename($csss), "/kaltst/lib/css/*.css");
        echo "<link rel='stylesheet' type='text/css' href='" . $url . "'>" . "\r\n";
    }
}
开发者ID:paveltashev,项目名称:kaltst,代码行数:13,代码来源:kaltst.php

示例14: retina_support_create_images

/**
 * Create retina-ready images
 *
 * Referenced via retina_support_attachment_meta().
 */
function retina_support_create_images($file, $width, $height, $crop = false)
{
    if ($width || $height) {
        $resized_file = wp_get_image_editor($file);
        if (!is_wp_error($resized_file)) {
            $filename = $resized_file->generate_filename($width . 'x' . $height . '@2x');
            $resized_file->resize($width * 2, $height * 2, $crop);
            $resized_file->save($filename);
            $info = $resized_file->get_size();
            return array('file' => wp_basename($filename), 'width' => $info['width'], 'height' => $info['height']);
        }
    }
    return false;
}
开发者ID:r1987,项目名称:plank_wp,代码行数:19,代码来源:retina-images-generator.php

示例15: activate

 /**
  * Activation Hook to check the theme name.
  *
  * Confirm site is using Genesis 2.0 or higher, or it's time to die.
  *
  * @since    1.0.0
  */
 public static function activate()
 {
     $latest = '2.0';
     $theme_info = wp_get_theme('genesis');
     if ('genesis' != wp_basename(get_template_directory())) {
         deactivate_plugins(plugin_basename(__FILE__));
         wp_die(sprintf(__('Sorry, to use Genesis Super Customizer you have to install and activate the <a href="%s">Genesis</a> theme first.', 'genesis-super-customizer'), 'http://supercustomizer.com/genesis'));
     }
     if (version_compare($theme_info['Version'], $latest, '<')) {
         deactivate_plugins(plugin_basename(__FILE__));
         // Deactivate plugin
         wp_die(sprintf(__('Sorry, you can\'t activate %1$sGenesis Super Customizer%2$s unless you have installed the %3$sGenesis %4$s%5$s. Go back to the %6$sPlugins Page%5$s.', 'genesis-super-customizer'), '<em>', '</em>', '<a href="http://supercustomizer.com/genesis" target="_blank">', $latest, '</a>', '<a href="javascript:history.back()">'));
     }
 }
开发者ID:jonpetersen,项目名称:PHTC,代码行数:21,代码来源:class-gsc-activator.php


注:本文中的wp_basename函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。