get_available_crop() public static method

Get all the available cropping
Author: Nicolas Juen
public static get_available_crop ( ) : array
return array
Ejemplo n.º 1
0
 /**
  * Add a size by Ajax
  * 
  * @access public
  * @return void
  * @author Nicolas Juen
  */
 public static function a_add_size()
 {
     // Get the nonce
     $nonce = isset($_POST['nonce']) ? $_POST['nonce'] : '';
     // Get old options
     $sizes = (array) get_option(SIS_OPTION, array());
     $croppings = SIS_Admin_Main::get_available_crop();
     $croppings[true] = '';
     $croppings[false] = '';
     // Check entries
     $name = isset($_POST['name']) ? sanitize_title($_POST['name']) : '';
     $height = !isset($_POST['height']) ? 0 : absint($_POST['height']);
     $width = !isset($_POST['width']) ? 0 : absint($_POST['width']);
     $crop = isset($_POST['crop']) && isset($croppings[$_POST['crop']]) ? $_POST['crop'] : false;
     $show = isset($_POST['show']) && $_POST['show'] == 'false' ? false : true;
     $cn = isset($_POST['customName']) && !empty($_POST['customName']) ? sanitize_text_field($_POST['customName']) : $name;
     // Check the nonce
     if (!wp_verify_nonce($nonce, 'add_size')) {
         die(0);
     }
     // If no name given do not save
     if (empty($name)) {
         die(0);
     }
     // Make values
     $values = array('custom' => 1, 'w' => $width, 'h' => $height, 'c' => $crop, 's' => $show, 'n' => $cn);
     // If the size have not changed return 2
     if (isset($sizes[$name]) && $sizes[$name] === $values) {
         die(2);
     }
     // Put the new values
     $sizes[$name] = $values;
     // display update result
     echo (int) update_option('custom_image_sizes', $sizes);
     die;
 }