示例#1
0
 public function __construct($slug, $desc = null, $params = array())
 {
     parent::__construct($slug, $desc, $params);
     add_action('wp_enqueue_scripts', function () {
         wp_enqueue_script('suggest');
     });
     add_action('wp_ajax_morepress_' . $this->_id . '_ajax', array($this, 'ajax'));
     add_action('wp_ajax_nopriv_morepress_' . $this->_id . '_ajax', array($this, 'ajax'));
 }
示例#2
0
 public function pre_save($post_id, $new, $old)
 {
     empty($new['hh']) and $new['hh'] = date('H');
     empty($new['mn']) and $new['mn'] = date('i');
     $new['hh'] = sprintf('%02d', $new['hh']);
     $new['mn'] = sprintf('%02d', $new['mn']);
     $new = implode('-', array($new['hh'], $new['mn']));
     return parent::pre_save($post_id, $new, $old);
 }
示例#3
0
 public function pre_save($post_id, $new, $old)
 {
     empty($new['aa']) and $new['aa'] = date('Y');
     empty($new['mm']) and $new['mm'] = date('m');
     empty($new['jj']) and $new['jj'] = date('d');
     $new['aa'] = sprintf('%04d', $new['aa']);
     $new['mm'] = sprintf('%02d', $new['mm']);
     $new['jj'] = sprintf('%02d', $new['jj']);
     $new = implode('-', array($new['aa'], $new['mm'], $new['jj']));
     return parent::pre_save($post_id, $new, $old);
 }
示例#4
0
 public function pre_save($post_id, $new, $old)
 {
     if (empty($new['lat']) or empty($new['lng']) and !empty($this->_params['geocode'])) {
         $address = array();
         foreach ($this->_params['geocode'] as $field) {
             empty($_POST[$field]) or $address[] = $_POST[$field];
         }
         if (!empty($address)) {
             try {
                 $curl = new \Ivory\HttpAdapter\CurlHttpAdapter();
                 $geocoder = new \Geocoder\Provider\GoogleMaps($curl);
                 $address_collection = $geocoder->geocode(implode(' ', $address));
                 if (!empty($address_collection)) {
                     $new['lat'] = $address_collection->first()->getLatitude();
                     $new['lng'] = $address_collection->first()->getLongitude();
                 }
             } catch (\Exception $ex) {
             }
         }
     }
     return parent::pre_save($post_id, $new, $old);
 }
示例#5
0
 public function __construct($slug, $desc = null, $params = array())
 {
     parent::__construct($slug, $desc, $params);
     add_action('admin_enqueue_scripts', array($this, 'action_admin_enqueue_scripts'));
 }
示例#6
0
 public function pre_save($post_id, $new, $old)
 {
     $new = implode('-', array($new['aa'], $new['mm'], $new['dd']));
     return parent::pre_save($post_id, $new, $old);
 }