當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wp_restore_image函數代碼示例

本文整理匯總了PHP中wp_restore_image函數的典型用法代碼示例。如果您正苦於以下問題:PHP wp_restore_image函數的具體用法?PHP wp_restore_image怎麽用?PHP wp_restore_image使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了wp_restore_image函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: wp_ajax_image_editor

/**
 * Ajax handler for image editing.
 *
 * @since 3.1.0
 */
function wp_ajax_image_editor()
{
    $attachment_id = intval($_POST['postid']);
    if (empty($attachment_id) || !current_user_can('edit_post', $attachment_id)) {
        wp_die(-1);
    }
    check_ajax_referer("image_editor-{$attachment_id}");
    include_once ABSPATH . 'wp-admin/includes/image-edit.php';
    $msg = false;
    switch ($_POST['do']) {
        case 'save':
            $msg = wp_save_image($attachment_id);
            $msg = wp_json_encode($msg);
            wp_die($msg);
            break;
        case 'scale':
            $msg = wp_save_image($attachment_id);
            break;
        case 'restore':
            $msg = wp_restore_image($attachment_id);
            break;
    }
    wp_image_editor($attachment_id, $msg);
    wp_die();
}
開發者ID:hughnet,項目名稱:WordPress,代碼行數:30,代碼來源:ajax-actions.php

示例2: die

         die('-1');
     }
     check_ajax_referer("image_editor-{$attachment_id}");
     include_once ABSPATH . 'wp-admin/includes/image-edit.php';
     $msg = false;
     switch ($_POST['do']) {
         case 'save':
             $msg = wp_save_image($attachment_id);
             $msg = json_encode($msg);
             die($msg);
             break;
         case 'scale':
             $msg = wp_save_image($attachment_id);
             break;
         case 'restore':
             $msg = wp_restore_image($attachment_id);
             break;
     }
     wp_image_editor($attachment_id, $msg);
     die;
     break;
 case 'set-post-thumbnail':
     $post_id = intval($_POST['post_id']);
     if (!current_user_can('edit_post', $post_id)) {
         die('-1');
     }
     $thumbnail_id = intval($_POST['thumbnail_id']);
     if ($thumbnail_id == '-1') {
         delete_post_meta($post_id, '_thumbnail_id');
         die(_wp_post_thumbnail_html());
     }
開發者ID:nagyist,項目名稱:laura-wordpress,代碼行數:31,代碼來源:admin-ajax.php


注:本文中的wp_restore_image函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。