Esempio n. 1
0
 public function get_attachment_sizes()
 {
     if (!defined('DOING_AJAX') || !DOING_AJAX) {
         return;
     }
     check_admin_referer('MMTL_Editor', MMTL_NONCE_NAME);
     if (empty($_POST['attachment'])) {
         wp_send_json_error();
     }
     $id = $_POST['attachment'];
     // makes sure we have an array (multiple urls possible)
     if (!is_array($id)) {
         $ids = array($id);
     } else {
         $ids = $id;
     }
     // gets sizes
     $sizes = array();
     foreach ($ids as $key => $value) {
         if (is_numeric($value)) {
             $attachment_id = $value;
         } else {
             $attachment_id = MMTL_Common::get_attachment_id_by_url($value);
         }
         if (!$attachment_id) {
             continue;
         }
         $attachment_sizes = MMTL_Common::get_attachment_sizes($attachment_id, 'url');
         if (empty($attachment_sizes)) {
             continue;
         }
         $sizes[$key] = $attachment_sizes;
     }
     // only give array back when posted url is array
     if (!is_array($id)) {
         if (count($sizes) > 0) {
             $sizes = $sizes[0];
         }
     }
     wp_send_json_success($sizes);
 }
Esempio n. 2
0
 public function enqueue_scripts()
 {
     if (!MMTL_Common::is_shortcode_used('mmtl-row')) {
         return;
     }
     wp_enqueue_style('table-layout');
 }