• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP pmxi_getExtension函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: process


//.........这里部分代码省略.........
                                                 }
                                             }
                                         }
                                         if ($this->options[$option_slug . 'set_image_meta_alt'] and !empty($image_meta_alts_bundle[$slug])) {
                                             $img_alts = array();
                                             $line_img_alts = explode("\n", $image_meta_alts_bundle[$slug][$i]);
                                             if (!empty($line_img_alts)) {
                                                 foreach ($line_img_alts as $line_img_alt) {
                                                     $img_alts = array_merge($img_alts, !empty($this->options[$option_slug . 'image_meta_alt_delim']) ? str_getcsv($line_img_alt, $this->options[$option_slug . 'image_meta_alt_delim']) : array($line_img_alt));
                                                 }
                                             }
                                         }
                                         if ($this->options[$option_slug . 'set_image_meta_description'] and !empty($image_meta_descriptions_bundle[$slug])) {
                                             $img_descriptions = array();
                                             $line_img_descriptions = explode("\n", $image_meta_descriptions_bundle[$slug][$i]);
                                             if (!empty($line_img_descriptions)) {
                                                 foreach ($line_img_descriptions as $line_img_description) {
                                                     $img_descriptions = array_merge($img_descriptions, !empty($this->options[$option_slug . 'image_meta_description_delim']) ? str_getcsv($line_img_description, $this->options[$option_slug . 'image_meta_description_delim']) : array($line_img_description));
                                                 }
                                             }
                                         }
                                         $is_keep_existing_images = (!empty($articleData['ID']) and $this->options['is_update_images'] and $this->options['update_images_logic'] == "add_new" and $this->options['update_all_data'] == "no" and $is_show_add_new_images);
                                         foreach ($imgs as $k => $img_url) {
                                             if (empty($img_url)) {
                                                 continue;
                                             }
                                             $attid = false;
                                             $attch = null;
                                             $url = str_replace(" ", "%20", trim($img_url));
                                             $bn = basename($url);
                                             if ("yes" == $this->options[$option_slug . 'download_images'] and !empty($auto_extensions_bundle[$slug][$i]) and preg_match('%^(jpg|jpeg|png|gif)$%i', $auto_extensions_bundle[$slug][$i])) {
                                                 $img_ext = $auto_extensions_bundle[$slug][$i];
                                             } else {
                                                 $img_ext = pmxi_getExtensionFromStr($url);
                                                 $default_extension = pmxi_getExtension($bn);
                                                 if ($img_ext == "") {
                                                     $img_ext = pmxi_get_remote_image_ext($url);
                                                 }
                                             }
                                             $logger and call_user_func($logger, sprintf(__('- Importing image `%s` for `%s` ...', 'wp_all_import_plugin'), $img_url, $articleData['post_title']));
                                             // generate local file name
                                             $image_name = urldecode(($this->options[$option_slug . 'auto_rename_images'] and !empty($auto_rename_images_bundle[$slug][$i])) ? sanitize_file_name($img_ext ? str_replace("." . $default_extension, "", $auto_rename_images_bundle[$slug][$i]) : $auto_rename_images_bundle[$slug][$i]) : sanitize_file_name($img_ext ? str_replace("." . $default_extension, "", $bn) : $bn)) . ("" != $img_ext ? '.' . $img_ext : '');
                                             // if wizard store image data to custom field
                                             $create_image = false;
                                             $download_image = true;
                                             $wp_filetype = false;
                                             if ($bundle_data['type'] == 'images' and base64_decode($url, true) !== false) {
                                                 $img = @imagecreatefromstring(base64_decode($url));
                                                 if ($img) {
                                                     $logger and call_user_func($logger, __('- Founded base64_encoded image', 'wp_all_import_plugin'));
                                                     $image_filename = md5(time()) . '.jpg';
                                                     $image_filepath = $targetDir . '/' . $image_filename;
                                                     imagejpeg($img, $image_filepath);
                                                     if (!($image_info = @getimagesize($image_filepath)) or !in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
                                                         $logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'wp_all_import_plugin'), $image_filepath));
                                                         $logger and !$is_cron and PMXI_Plugin::$session->warnings++;
                                                     } else {
                                                         $create_image = true;
                                                     }
                                                 }
                                             } else {
                                                 $image_filename = wp_unique_filename($targetDir, $image_name);
                                                 $image_filepath = $targetDir . '/' . $image_filename;
                                                 // keep existing and add newest images
                                                 if ($is_keep_existing_images) {
                                                     $attch = $this->wpdb->get_row($this->wpdb->prepare("SELECT * FROM " . $this->wpdb->posts . " WHERE (post_title = %s OR post_title = %s OR post_name = %s) AND post_type = %s AND post_parent = %d;", $image_name, preg_replace('/\\.[^.\\s]{3,4}$/', '', $image_name), sanitize_title($image_name), "attachment", $pid));
开发者ID:k-hasan-19,项目名称:wp-all-import,代码行数:67,代码来源:record.php


示例2: upload_image

 public static function upload_image($pid, $img_url, $download_images, $logger, $create_image = false, $image_name = "", $file_type = 'images')
 {
     if (empty($img_url)) {
         return false;
     }
     $url = str_replace(" ", "%20", trim($img_url));
     $bn = wp_all_import_sanitize_filename(basename($url));
     if ($image_name == "") {
         $img_ext = pmxi_getExtensionFromStr($url);
         $default_extension = pmxi_getExtension($bn);
         if ($img_ext == "") {
             $img_ext = pmxi_get_remote_image_ext($url);
         }
         // generate local file name
         $image_name = apply_filters("wp_all_import_image_filename", urldecode(sanitize_file_name($img_ext ? str_replace("." . $default_extension, "", $bn) : $bn)) . ("" != $img_ext ? '.' . $img_ext : ''));
     }
     $uploads = wp_upload_dir();
     $targetDir = $uploads['path'];
     $targetUrl = $uploads['url'];
     $download_image = true;
     $result = false;
     $wp_filetype = false;
     global $wpdb;
     $attch = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->posts . " WHERE (post_title = %s OR post_title = %s OR post_name = %s) AND post_type = %s AND post_mime_type LIKE %s;", $image_name, preg_replace('/\\.[^.\\s]{3,4}$/', '', $image_name), sanitize_title($image_name), "attachment", "image%"));
     if ($attch != null) {
         return $attch->ID;
     }
     $image_filename = wp_unique_filename($targetDir, $image_name);
     $image_filepath = $targetDir . '/' . $image_filename;
     // do not download images
     if ("yes" != $download_images) {
         $image_filename = $image_name;
         $image_filepath = $targetDir . '/' . $image_filename;
         $wpai_uploads = $uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::FILES_DIRECTORY . DIRECTORY_SEPARATOR;
         $wpai_image_path = $wpai_uploads . str_replace('%20', ' ', $url);
         $logger and call_user_func($logger, sprintf(__('- Searching for existing image `%s` in `%s` folder', 'wp_all_import_plugin'), $wpai_image_path, $wpai_uploads));
         if (@file_exists($wpai_image_path) and @copy($wpai_image_path, $image_filepath)) {
             $download_image = false;
             // valdate import attachments
             if ($file_type == 'files') {
                 if (!($wp_filetype = wp_check_filetype(basename($image_filepath), null))) {
                     $logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: Can\'t detect attachment file type %s', 'wp_all_import_plugin'), trim($image_filepath)));
                     $logger and !$is_cron and PMXI_Plugin::$session->warnings++;
                     @unlink($image_filepath);
                 } else {
                     $result = true;
                     $logger and call_user_func($logger, sprintf(__('- File `%s` has been successfully found', 'wp_all_import_plugin'), $wpai_image_path));
                 }
             } elseif ($file_type == 'images') {
                 if (!($image_info = @getimagesize($image_filepath)) or !in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
                     $logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'wp_all_import_plugin'), $image_filepath));
                     @unlink($image_filepath);
                 } else {
                     $logger and call_user_func($logger, sprintf(__('- Image `%s` has been successfully found', 'wp_all_import_plugin'), $wpai_image_path));
                     $result = true;
                 }
             }
         }
     }
     if ($download_image) {
         if ($file_type == 'images') {
             $logger and call_user_func($logger, sprintf(__('- Downloading image from `%s`', 'wp_all_import_plugin'), $url));
         } elseif ($file_type == 'files') {
             $logger and call_user_func($logger, sprintf(__('- Downloading file from `%s`', 'wp_all_import_plugin'), $url));
         }
         $request = get_file_curl($url, $image_filepath);
         if ((is_wp_error($request) or $request === false) and !@file_put_contents($image_filepath, @file_get_contents($url))) {
             @unlink($image_filepath);
             // delete file since failed upload may result in empty file created
         } else {
             if ($file_type == 'images') {
                 if ($image_info = @getimagesize($image_filepath) and in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
                     $result = true;
                     $logger and call_user_func($logger, sprintf(__('- Image `%s` has been successfully downloaded', 'wp_all_import_plugin'), $url));
                 }
             } elseif ($file_type == 'files') {
                 if ($wp_filetype = wp_check_filetype(basename($image_filepath), null)) {
                     $result = true;
                     $logger and call_user_func($logger, sprintf(__('- File `%s` has been successfully downloaded', 'wp_all_import_plugin'), $url));
                 }
             }
         }
         if (!$result) {
             $url = str_replace(" ", "%20", trim(pmxi_convert_encoding($img_url)));
             $request = get_file_curl($url, $image_filepath);
             if ((is_wp_error($request) or $request === false) and !@file_put_contents($image_filepath, @file_get_contents($url))) {
                 $logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: File %s cannot be saved locally as %s', 'wp_all_import_plugin'), $url, $image_filepath));
                 @unlink($image_filepath);
                 // delete file since failed upload may result in empty file created
             } else {
                 if ($file_type == 'images') {
                     if (!($image_info = @getimagesize($image_filepath)) or !in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
                         $logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'wp_all_import_plugin'), $url));
                         @unlink($image_filepath);
                     } else {
                         $result = true;
                         $logger and call_user_func($logger, sprintf(__('- Image `%s` has been successfully downloaded', 'wp_all_import_plugin'), $url));
                     }
                 } elseif ($file_type == 'files') {
                     if (!($wp_filetype = wp_check_filetype(basename($image_filepath), null))) {
//.........这里部分代码省略.........
开发者ID:lizbur10,项目名称:js_finalproject,代码行数:101,代码来源:api.php


示例3: _e

						
						<?php 
            }
            ?>
 					
					</ul>
					<h4><?php 
            _e('Here are the above URLs, in &lt;img&gt; tags. ');
            ?>
</h4>
					
					<?php 
            foreach ($imgs as $img) {
                $bn = wp_all_import_sanitize_filename(basename($img));
                $img_ext = pmxi_getExtensionFromStr($img);
                $default_extension = pmxi_getExtension($bn);
                $image_name = apply_filters("wp_all_import_image_filename", urldecode(sanitize_file_name($img_ext ? str_replace("." . $default_extension, "", $bn) : $bn)) . ("" != $img_ext ? '.' . $img_ext : ''));
                $attch = wp_all_import_get_image_from_gallery($image_name);
                $img_url = empty($attch) ? '' : trim(wp_get_attachment_url($attch->ID));
                ?>
						<img src="<?php 
                echo trim($img_url);
                ?>
" style="width:64px; margin:5px; vertical-align:top;"/>
						<?php 
            }
            break;
            // Download images hosted elsewhere
        // Download images hosted elsewhere
        default:
            ?>
开发者ID:estrategasdigitales,项目名称:rufiatta,代码行数:30,代码来源:preview_images.php


示例4: index

 public function index()
 {
     $this->data['post'] = $post = $this->input->post(PMXI_Plugin::getInstance()->getOption());
     /*$addons = new PMXI_Admin_Addons();
     
     		$this->data['addons'] = $addons->get_premium_addons();*/
     $this->data['addons']['PMXI_Plugin'] = array('title' => __('WP All Import', 'wp_all_import_plugin'), 'active' => class_exists('PMXI_Plugin') and defined('PMXI_EDITION') and PMXI_EDITION == 'paid');
     $this->data['addons'] = array_reverse($this->data['addons']);
     if ($this->input->post('is_settings_submitted')) {
         // save settings form
         check_admin_referer('edit-settings', '_wpnonce_edit-settings');
         if (!preg_match('%^\\d+$%', $post['history_file_count'])) {
             $this->errors->add('form-validation', __('History File Count must be a non-negative integer', 'wp_all_import_plugin'));
         }
         if (!preg_match('%^\\d+$%', $post['history_file_age'])) {
             $this->errors->add('form-validation', __('History Age must be a non-negative integer', 'wp_all_import_plugin'));
         }
         if (empty($post['html_entities'])) {
             $post['html_entities'] = 0;
         }
         if (empty($post['utf8_decode'])) {
             $post['utf8_decode'] = 0;
         }
         if (!$this->errors->get_error_codes()) {
             // no validation errors detected
             PMXI_Plugin::getInstance()->updateOption($post);
             if (empty($_POST['pmxi_license_activate']) and empty($_POST['pmxi_license_deactivate'])) {
                 foreach ($this->data['addons'] as $class => $addon) {
                     $post['statuses'][$class] = $this->check_license($class);
                 }
                 PMXI_Plugin::getInstance()->updateOption($post);
             }
             isset($_POST['pmxi_license_activate']) and $this->activate_licenses();
             $files = new PMXI_File_List();
             $files->sweepHistory();
             // adjust file history to new settings specified
             wp_redirect(add_query_arg('pmxi_nt', urlencode(__('Settings saved', 'wp_all_import_plugin')), $this->baseUrl));
             die;
         }
     }
     /*else{			
     
     			foreach ($this->data['addons'] as $class => $addon) {
     				$post['statuses'][$class] = $this->check_license($class);
     			}								
     
     			PMXI_Plugin::getInstance()->updateOption($post);	
     		}*/
     if ($this->input->post('is_templates_submitted')) {
         // delete templates form
         check_admin_referer('delete-templates', '_wpnonce_delete-templates');
         if ($this->input->post('import_templates')) {
             if (!empty($_FILES)) {
                 $file_name = $_FILES['template_file']['name'];
                 $file_size = $_FILES['template_file']['size'];
                 $tmp_name = $_FILES['template_file']['tmp_name'];
                 if (isset($file_name)) {
                     $filename = stripslashes($file_name);
                     $extension = strtolower(pmxi_getExtension($filename));
                     if ($extension != "txt") {
                         $this->errors->add('form-validation', __('Unknown File extension. Only txt files are permitted', 'wp_all_import_plugin'));
                     } else {
                         $import_data = @file_get_contents($tmp_name);
                         if (!empty($import_data)) {
                             $templates_data = json_decode($import_data, true);
                             if (!empty($templates_data)) {
                                 $template = new PMXI_Template_Record();
                                 foreach ($templates_data as $template_data) {
                                     unset($template_data['id']);
                                     $template->clear()->set($template_data)->insert();
                                 }
                                 wp_redirect(add_query_arg('pmxi_nt', urlencode(sprintf(_n('%d template imported', '%d templates imported', count($templates_data), 'wp_all_import_plugin'), count($templates_data))), $this->baseUrl));
                                 die;
                             } else {
                                 $this->errors->add('form-validation', __('Wrong imported data format', 'wp_all_import_plugin'));
                             }
                         } else {
                             $this->errors->add('form-validation', __('File is empty or doesn\'t exests', 'wp_all_import_plugin'));
                         }
                     }
                 } else {
                     $this->errors->add('form-validation', __('Undefined entry!', 'wp_all_import_plugin'));
                 }
             } else {
                 $this->errors->add('form-validation', __('Please select file.', 'wp_all_import_plugin'));
             }
         } else {
             $templates_ids = $this->input->post('templates', array());
             if (empty($templates_ids)) {
                 $this->errors->add('form-validation', __('Templates must be selected', 'wp_all_import_plugin'));
             }
             if (!$this->errors->get_error_codes()) {
                 // no validation errors detected
                 if ($this->input->post('delete_templates')) {
                     $template = new PMXI_Template_Record();
                     foreach ($templates_ids as $template_id) {
                         $template->clear()->set('id', $template_id)->delete();
                     }
                     wp_redirect(add_query_arg('pmxi_nt', urlencode(sprintf(_n('%d template deleted', '%d templates deleted', count($templates_ids), 'wp_all_import_plugin'), count($templates_ids))), $this->baseUrl));
                     die;
//.........这里部分代码省略.........
开发者ID:hikaram,项目名称:wee,代码行数:101,代码来源:settings.php


示例5: _e

if (!empty($upload_validation)) {
    ?>
 style="display:block;" <?php 
}
?>
>
						<div class="wpallimport-notify-wrapper">
							<div class="error-headers exclamation">
								<h3><?php 
_e('There\'s a problem with your import file', 'wp_all_import_plugin');
?>
</h3>
								<h4>
									<?php 
if (!empty($upload_validation)) {
    $file_type = strtoupper(pmxi_getExtension($post['file']));
    printf(__('Please verify that the file you using is a valid %s file.', 'wp_all_import_plugin'), $file_type);
}
?>
								</h4>
							</div>		
						</div>		
						<a class="button button-primary button-hero wpallimport-large-button wpallimport-notify-read-more" href="http://www.wpallimport.com/documentation/troubleshooting/problems-with-import-files/#invalid" target="_blank"><?php 
_e('Read More', 'wp_all_import_plugin');
?>
</a>		
					</div>	

					<div class="wpallimport-free-edition-notice wpallimport-import-orders-notice" style="text-align:center; margin-top:20px; margin-bottom: 40px; display: none;">
						<a href="http://www.wpallimport.com/upgrade-to-pro/?utm_source=free-plugin&utm_medium=in-plugin&utm_campaign=custom-fields" target="_blank" class="upgrade_link"><?php 
_e('Upgrade to the Pro edition of WooCommerce add-on to import WooCommerce Orders.', 'wp_all_import_plugin');
开发者ID:TakenCdosG,项目名称:chefs,代码行数:31,代码来源:index.php


示例6: pmxi_wp_ajax_test_images

function pmxi_wp_ajax_test_images()
{
    if (!check_ajax_referer('wp_all_import_secure', 'security', false)) {
        exit(json_encode(array('result' => array(), 'failed_msgs' => array(__('Security check', 'wp_all_import_plugin')))));
    }
    if (!current_user_can(PMXI_Plugin::$capabilities)) {
        exit(json_encode(array('result' => array(), 'failed_msgs' => array(__('Security check', 'wp_all_import_plugin')))));
    }
    $input = new PMXI_Input();
    $post = $input->post(array('download' => 'yes', 'imgs' => array()));
    $result = array();
    $wp_uploads = wp_upload_dir();
    $imgs_basedir = $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::FILES_DIRECTORY . DIRECTORY_SEPARATOR;
    $targetDir = $wp_uploads['path'];
    $success_images = 0;
    $success_msg = '';
    $failed_msgs = array();
    if (!@is_writable($targetDir)) {
        $failed_msgs[] = sprintf(__('Uploads folder `%s` is not writable.', 'wp_all_import_plugin'), $targetDir);
    } else {
        switch ($post['download']) {
            // Use images currently uploaded in wp-content/uploads/wpallimport/files/
            case 'no':
                if (!empty($post['imgs'])) {
                    foreach ($post['imgs'] as $img) {
                        if (preg_match('%^(http|https|ftp|ftps)%i', $img)) {
                            $failed_msgs[] = sprintf(__('Use image name instead of URL `%s`.', 'wp_all_import_plugin'), $img);
                            continue;
                        }
                        if (@file_exists($imgs_basedir . $img)) {
                            if (@is_readable($imgs_basedir . $img)) {
                                $success_images++;
                            } else {
                                $failed_msgs[] = sprintf(__('File `%s` isn\'t readable', 'wp_all_import_plugin'), preg_replace('%.*/wp-content%', '/wp-content', $imgs_basedir . $img));
                            }
                        } else {
                            $failed_msgs[] = sprintf(__('File `%s` doesn\'t exist', 'wp_all_import_plugin'), preg_replace('%.*/wp-content%', '/wp-content', $imgs_basedir . $img));
                        }
                    }
                }
                if ((int) $success_images === 1) {
                    $success_msg = sprintf(__('%d image was successfully retrieved from `%s`', 'wp_all_import_plugin'), $success_images, preg_replace('%.*/wp-content%', '/wp-content', $wp_uploads['basedir']) . DIRECTORY_SEPARATOR . PMXI_Plugin::FILES_DIRECTORY);
                } elseif ((int) $success_images > 1) {
                    $success_msg = sprintf(__('%d images were successfully retrieved from `%s`', 'wp_all_import_plugin'), $success_images, preg_replace('%.*/wp-content%', '/wp-content', $wp_uploads['basedir']) . DIRECTORY_SEPARATOR . PMXI_Plugin::FILES_DIRECTORY);
                }
                break;
                // 	Use images currently in Media Library
            // 	Use images currently in Media Library
            case 'gallery':
                if (!empty($post['imgs'])) {
                    global $wpdb;
                    foreach ($post['imgs'] as $img) {
                        $bn = wp_all_import_sanitize_filename(basename($img));
                        $img_ext = pmxi_getExtensionFromStr($img);
                        $default_extension = pmxi_getExtension($bn);
                        $image_name = apply_filters("wp_all_import_image_filename", urldecode(sanitize_file_name($img_ext ? str_replace("." . $default_extension, "", $bn) : $bn)) . ("" != $img_ext ? '.' . $img_ext : ''));
                        $attch = wp_all_import_get_image_from_gallery($image_name, $targetDir);
                        if (!empty($attch)) {
                            $success_images++;
                        } else {
                            $failed_msgs[] = sprintf(__('Image `%s` not found in media library.', 'wp_all_import_plugin'), $image_name);
                        }
                    }
                }
                if ((int) $success_images === 1) {
                    $success_msg = sprintf(__('%d image was successfully founded in media gallery', 'wp_all_import_plugin'), $success_images);
                } elseif ((int) $success_images > 1) {
                    $success_msg = sprintf(__('%d images were successfully founded in media gallery', 'wp_all_import_plugin'), $success_images);
                }
                break;
                // Download images hosted elsewhere
            // Download images hosted elsewhere
            default:
                $start = time();
                if (!empty($post['imgs'])) {
                    foreach ($post['imgs'] as $img) {
                        if (!preg_match('%^(http|https|ftp|ftps)%i', $img)) {
                            $failed_msgs[] = sprintf(__('URL `%s` is not valid.', 'wp_all_import_plugin'), $img);
                            continue;
                        }
                        $image_name = wp_unique_filename($targetDir, 'test');
                        $image_filepath = $targetDir . '/' . $image_name;
                        $url = trim($img);
                        $request = get_file_curl($url, $image_filepath);
                        $get_ctx = stream_context_create(array('http' => array('timeout' => 5)));
                        if ((is_wp_error($request) or $request === false) and !@file_put_contents($image_filepath, @file_get_contents($img, false, $get_ctx))) {
                            $failed_msgs[] = is_wp_error($request) ? $request->get_error_message() : sprintf(__('File `%s` cannot be saved locally', 'wp_all_import_plugin'), $img);
                        } elseif (!($image_info = apply_filters('pmxi_getimagesize', @getimagesize($image_filepath), $image_filepath)) or !in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
                            $failed_msgs[] = sprintf(__('File `%s` is not a valid image.', 'wp_all_import_plugin'), $img);
                        } else {
                            $success_images++;
                        }
                        @unlink($image_filepath);
                    }
                }
                $time = time() - $start;
                if ((int) $success_images === 1) {
                    $success_msg = sprintf(__('%d image was successfully downloaded in %s seconds', 'wp_all_import_plugin'), $success_images, number_format($time, 2));
                } elseif ((int) $success_images > 1) {
                    $success_msg = sprintf(__('%d images were successfully downloaded in %s seconds', 'wp_all_import_plugin'), $success_images, number_format($time, 2));
//.........这里部分代码省略.........
开发者ID:TakenCdosG,项目名称:chefs,代码行数:101,代码来源:wp_ajax_test_images.php


示例7: process


//.........这里部分代码省略.........
                         }
                     } else {
                         $import_func = $class . '_import';
                         if (function_exists($import_func)) {
                             call_user_func($import_func, $importData, $addons_data[$class]);
                         }
                     }
                 }
                 // [/addons import]
                 // Page Template
                 if ('post' != $articleData['post_type'] and !empty($this->options['page_template'])) {
                     update_post_meta($pid, '_wp_page_template', $this->options['page_template']);
                 }
                 // [featured image]
                 if (!empty($uploads) and false === $uploads['error'] and !empty($featured_images[$i]) and (empty($articleData['ID']) or $this->options['update_all_data'] == "yes" or $this->options['update_all_data'] == "no" and $this->options['is_update_images'])) {
                     require_once ABSPATH . 'wp-admin/includes/image.php';
                     $success_images = false;
                     $gallery_attachment_ids = array();
                     $_pmxi_images = array();
                     $imgs = !empty($this->options['featured_delim']) ? str_getcsv($featured_images[$i], $this->options['featured_delim']) : explode("\n", $featured_images[$i]);
                     if (!empty($imgs)) {
                         if ($this->options['set_image_meta_data']) {
                             $img_titles = !empty($this->options['image_meta_title_delim']) ? str_getcsv($image_meta_titles[$i], $this->options['image_meta_title_delim']) : explode("\n", $image_meta_titles[$i]);
                             $img_captions = !empty($this->options['image_meta_caption_delim']) ? str_getcsv($image_meta_captions[$i], $this->options['image_meta_caption_delim']) : explode("\n", $image_meta_captions[$i]);
                             $img_alts = !empty($this->options['image_meta_alt_delim']) ? str_getcsv($image_meta_alts[$i], $this->options['image_meta_alt_delim']) : explode("\n", $image_meta_alts[$i]);
                             $img_descriptions = !empty($this->options['image_meta_description_delim']) ? str_getcsv($image_meta_descriptions[$i], $this->options['image_meta_description_delim']) : explode("\n", $image_meta_descriptions[$i]);
                         }
                         foreach ($imgs as $k => $img_url) {
                             if (empty($img_url)) {
                                 continue;
                             }
                             $url = str_replace(" ", "%20", trim($img_url));
                             $bn = preg_replace('/[\\?|&].*/', '', basename($url));
                             $img_ext = pmxi_getExtensionFromStr($url);
                             $default_extension = pmxi_getExtension($bn);
                             if ($img_ext == "") {
                                 $img_ext = pmxi_get_remote_image_ext($url);
                             }
                             // generate local file name
                             $image_name = urldecode(($this->options['auto_rename_images'] and "" != $auto_rename_images[$i]) ? sanitize_file_name($auto_rename_images[$i] . '_' . ($img_ext ? str_replace("." . $default_extension, "", $bn) : $bn)) : sanitize_file_name($img_ext ? str_replace("." . $default_extension, "", $bn) : $bn)) . ("" != $img_ext ? '.' . $img_ext : '');
                             // if wizard store image data to custom field
                             $create_image = false;
                             $download_image = true;
                             if (base64_decode($url, true) !== false) {
                                 $img = @imagecreatefromstring(base64_decode($url));
                                 if ($img) {
                                     $image_filename = md5(time()) . '.jpg';
                                     $image_filepath = $uploads['path'] . '/' . $image_filename;
                                     imagejpeg($img, $image_filepath);
                                     if (!($image_info = @getimagesize($image_filepath)) or !in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
                                         $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'pmxi_plugin'), $image_filepath));
                                         $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
                                     } else {
                                         $create_image = true;
                                     }
                                 }
                             } else {
                                 $image_filename = wp_unique_filename($uploads['path'], $image_name);
                                 $image_filepath = $uploads['path'] . '/' . $image_filename;
                                 // keep existing and add newest images
                                 if (!empty($articleData['ID']) and $this->options['is_update_images'] and $this->options['update_images_logic'] == "add_new" and $this->options['update_all_data'] == "no") {
                                     $attachment_imgs = get_posts(array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_parent' => $pid));
                                     if ($attachment_imgs) {
                                         foreach ($attachment_imgs as $attachment_img) {
                                             if ($attachment_img->guid == $uploads['url'] . '/' . $image_name) {
                                                 $download_image = false;
开发者ID:thabofletcher,项目名称:tc-site,代码行数:67,代码来源:record.php


示例8: upload


//.........这里部分代码省略.........
            }
        }
        $post_type = false;
        // Check if file has been uploaded
        if (!$chunks || $chunk == $chunks - 1) {
            // Strip the temp .part suffix off
            rename("{$filePath}.part", $filePath);
            chmod($filePath, 0755);
            delete_transient(self::$upload_transient);
            $errors = new WP_Error();
            $uploader = new PMXI_Upload($filePath, $errors, rtrim(str_replace(basename($filePath), '', $filePath), '/'));
            $upload_result = $uploader->upload();
            if ($upload_result instanceof WP_Error) {
                $errors = $upload_result;
                $msgs = $errors->get_error_messages();
                ob_start();
                ?>
				<?php 
                foreach ($msgs as $msg) {
                    ?>
					<p><?php 
                    echo $msg;
                    ?>
</p>
				<?php 
                }
                ?>
				<?php 
                $response = ob_get_clean();
                exit(json_encode(array("jsonrpc" => "2.0", "error" => array("code" => 102, "message" => $response), "id" => "id")));
            } else {
                if (!empty($upload_result['post_type'])) {
                    $post_type = $upload_result['post_type'];
                }
                if (!empty($upload_result['is_empty_bundle_file'])) {
                    // Return JSON-RPC response
                    exit(json_encode(array("jsonrpc" => "2.0", "error" => null, "result" => null, "id" => "id", "name" => $upload_result['filePath'], "post_type" => $post_type, "template" => $upload_result['template'], "url_bundle" => true)));
                } else {
                    // validate XML
                    $file = new PMXI_Chunk($upload_result['filePath'], array('element' => $upload_result['root_element']));
                    $is_valid = true;
                    if (!empty($file->options['element'])) {
                        $defaultXpath = "/" . $file->options['element'];
                    } else {
                        $is_valid = false;
                    }
                    if ($is_valid) {
                        while ($xml = $file->read()) {
                            if (!empty($xml)) {
                                //PMXI_Import_Record::preprocessXml($xml);
                                $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . "\n" . $xml;
                                $dom = new DOMDocument('1.0', 'UTF-8');
                                $old = libxml_use_internal_errors(true);
                                $dom->loadXML($xml);
                                libxml_use_internal_errors($old);
                                $xpath = new DOMXPath($dom);
                                if ($elements = $xpath->query($defaultXpath) and $elements->length) {
                                    break;
                                }
                            }
                            /*else {
                              	$is_valid = false;
                              	break;
                              }*/
                        }
                        if (empty($xml)) {
                            $is_valid = false;
                        }
                    }
                    unset($file);
                    if (!preg_match('%\\W(xml)$%i', trim($upload_result['source']['path']))) {
                        @unlink($upload_result['filePath']);
                    }
                    if (!$is_valid) {
                        ob_start();
                        ?>
						
						<div class="error inline"><p><?php 
                        _e('Please confirm you are importing a valid feed.<br/> Often, feed providers distribute feeds with invalid data, improperly wrapped HTML, line breaks where they should not be, faulty character encodings, syntax errors in the XML, and other issues.<br/><br/>WP All Import has checks in place to automatically fix some of the most common problems, but we can’t catch every single one.<br/><br/>It is also possible that there is a bug in WP All Import, and the problem is not with the feed.<br/><br/>If you need assistance, please contact support – <a href="mailto:[email protected]">[email protected]</a> – with your XML/CSV file. We will identify the problem and release a bug fix if necessary.', 'wp_all_import_plugin');
                        ?>
</p></div>
						
						<?php 
                        $response = ob_get_clean();
                        $file_type = strtoupper(pmxi_getExtension($upload_result['source']['path']));
                        $error_message = sprintf(__("Please verify that the file you uploading is a valid %s file.", "wp_all_import_plugin"), $file_type);
                        exit(json_encode(array("jsonrpc" => "2.0", "error" => array("code" => 102, "message" => $error_message), "is_valid" => false, "id" => "id")));
                    } else {
                        $wp_uploads = wp_upload_dir();
                        $uploads = $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::FILES_DIRECTORY . DIRECTORY_SEPARATOR;
                        if (!file_exists($uploads . basename($filePath))) {
                            @copy($filePath, $uploads . basename($filePath));
                        }
                    }
                }
            }
        }
        // Return JSON-RPC response
        exit(json_encode(array("jsonrpc" => "2.0", "error" => null, "result" => null, "id" => "id", "name" => $filePath, "post_type" => $post_type)));
    }
开发者ID:Darkers54,项目名称:eLEGO,代码行数:101,代码来源:settings.php


示例9: import


//.........这里部分代码省略.........
                                         $term = wp_insert_term($values, wc_attribute_taxonomy_name($a_name));
                                     }
                                 }
                             }
                             if (!is_wp_error($term)) {
                                 $term = get_term_by('id', $term['term_id'], wc_attribute_taxonomy_name($a_name));
                                 update_post_meta($variation_to_update_id, 'attribute_' . sanitize_title($attr_name), $term->slug);
                             }
                         } else {
                             update_post_meta($variation_to_update_id, 'attribute_' . sanitize_title($attr_name), $values);
                         }
                     }
                 }
                 if (!is_array($variation_image[$j])) {
                     $variation_image[$j] = array($variation_image[$j]);
                 }
                 $uploads = wp_upload_dir();
                 if (!empty($uploads) and false === $uploads['error'] and !empty($variation_image[$j]) and (empty($articleData['ID']) or $this->import->options['update_all_data'] == "yes" or $this->import->options['update_all_data'] == "no" and $this->import->options['is_update_images'])) {
                     require_once ABSPATH . 'wp-admin/includes/image.php';
                     $targetDir = $uploads['path'];
                     $targetUrl = $uploads['url'];
                     $gallery_attachment_ids = array();
                     foreach ($variation_image[$j] as $featured_image) {
                         $imgs = explode(',', $featured_image);
                         if (!empty($imgs)) {
                             foreach ($imgs as $img_url) {
                                 if (empty($img_url)) {
                                     continue;
                                 }
                                 $attid = false;
                                 $attch = null;
                                 $url = str_replace(" ", "%20", trim($img_url));
                                 $bn = wp_all_import_sanitize_filename(basename($url));
                                 $img_ext = pmxi_getExtensionFromStr($url);
                                 $default_extension = pmxi_getExtension($bn);
                                 if ($img_ext == "") {
                                     $img_ext = pmxi_get_remote_image_ext($url);
                                 }
                                 // generate local file name
                                 $image_name = apply_filters("wp_all_import_image_filename", urldecode(sanitize_file_name($img_ext ? str_replace("." . $default_extension, "", $bn) : $bn)) . ("" != $img_ext ? '.' . $img_ext : ''));
                                 // if wizard store image data to custom field
                                 $create_image = false;
                                 $download_image = true;
                                 $image_filename = wp_unique_filename($uploads['path'], $image_name);
                                 $image_filepath = $uploads['path'] . DIRECTORY_SEPARATOR . $image_filename;
                                 // search existing attachment
                                 if ($this->import->options['search_existing_images'] or "gallery" == $this->import->options['download_images']) {
                                     $image_filename = $image_name;
                                     $attch = wp_all_import_get_image_from_gallery($image_name, $targetDir, "images");
                                     if ("gallery" == $this->import->options['download_images']) {
                                         $download_image = false;
                                     }
                                     if (empty($attch)) {
                                         $logger and call_user_func($logger, sprintf(__('- <b>WARNING</b>: Image %s not found in media gallery.', 'wp_all_import_plugin'), trim($image_name)));
                                     } else {
                                         $logger and call_user_func($logger, sprintf(__('- Using existing image `%s` for post `%s` ...', 'wp_all_import_plugin'), trim($image_name), $variation_post_title));
                                         $download_image = false;
                                         $create_image = false;
                                         $attid = $attch->ID;
                                     }
                                 }
                                 if ($download_image && "gallery" != $this->import->options['download_images']) {
                                     // do not download images
                                     if ("no" == $this->import->options['download_images']) {
                                         $image_filename = $image_name;
                                         $image_filepath = $targetDir . DIRECTORY_SEPARATOR . $image_filename;
开发者ID:estrategasdigitales,项目名称:rufiatta,代码行数:67,代码来源:XmlImportWooCommerceProduct.php


示例10: index

 public function index()
 {
     $this->data['post'] = $post = $this->input->post(PMXE_Plugin::getInstance()->getOption());
     if ($this->input->post('is_settings_submitted')) {
         // save settings form
         check_admin_referer('edit-settings', '_wpnonce_edit-settings');
         if (!$this->errors->get_error_codes()) {
             // no validation errors detected
             PMXE_Plugin::getInstance()->updateOption($post);
             wp_redirect(add_query_arg('pmxe_nt', urlencode(__('Settings saved', 'pmxe_plugin')), $this->baseUrl));
             die;
         }
     }
     if ($this->input->post('is_templates_submitted')) {
         // delete templates form
         check_admin_referer('delete-templates', '_wpnonce_delete-templates');
         if ($this->input->post('import_templates')) {
             if (!empty($_FILES)) {
                 $file_name = $_FILES['template_file']['name'];
                 $file_size = $_FILES['template_file']['size'];
                 $tmp_name = $_FILES['template_file']['tmp_name'];
                 if (isset($file_name)) {
                     $filename = stripslashes($file_name);
                     $extension = strtolower(pmxi_getExtension($filename));
                     if ($extension != "txt") {
                         $this->errors->add('form-validation', __('Unknown File extension. Only txt files are permitted', 'wp_all_export_plugin'));
                     } else {
                         $import_data = @file_get_contents($tmp_name);
                         if (!empty($import_data)) {
                             $templates_data = json_decode($import_data, true);
                             if (!empty($templates_data)) {
                                 $template = new PMXE_Template_Record();
                                 foreach ($templates_data as $template_data) {
                                     unset($template_data['id']);
                                     $template->clear()->set($template_data)->insert();
                                 }
                                 wp_redirect(add_query_arg('pmxi_nt', urlencode(sprintf(_n('%d template imported', '%d templates imported', count($templates_data), 'wp_all_export_plugin'), count($templates_data))), $this->baseUrl));
                                 die;
                             } else {
                                 $this->errors->add('form-validation', __('Wrong imported data format', 'wp_all_export_plugin'));
                             }
                         } else {
                             $this->errors->add('form-validation', __('File is empty or  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP pnConfigGetVar函数代码示例发布时间:2022-05-15
下一篇:
PHP pmpro_url函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap