Beispiel #1
0
 public function init_scripts()
 {
     if (self::$enqueued_scripts) {
         return;
     }
     wp_enqueue_style('p2p-box', plugins_url('box.css', __FILE__), array(), P2P_PLUGIN_VERSION);
     wp_enqueue_script('p2p-box', plugins_url('box.js', __FILE__), array('jquery'), P2P_PLUGIN_VERSION, true);
     wp_localize_script('p2p-box', 'P2PAdmin', array('nonce' => wp_create_nonce(P2P_BOX_NONCE), 'spinner' => admin_url('images/wpspin_light.gif'), 'deleteConfirmMessage' => __('Are you sure you want to delete all connections?', P2P_TEXTDOMAIN)));
     self::$enqueued_scripts = true;
 }
 public function init_scripts()
 {
     if (self::$enqueued_scripts) {
         return;
     }
     wp_enqueue_style('p2p-box', plugins_url('box.css', __FILE__), array(), P2P_PLUGIN_VERSION);
     wp_register_script('mustache', plugins_url('mustache.js', __FILE__), array(), '0.7.2', true);
     wp_enqueue_script('p2p-box', plugins_url('box.js', __FILE__), array('backbone', 'mustache'), P2P_PLUGIN_VERSION, true);
     wp_localize_script('p2p-box', 'P2PAdminL10n', array('nonce' => wp_create_nonce(P2P_BOX_NONCE), 'spinner' => admin_url('images/wpspin_light.gif'), 'deleteConfirmMessage' => __('Are you sure you want to delete all connections?', P2P_TEXTDOMAIN)));
     self::$enqueued_scripts = true;
     add_action('admin_footer', array(__CLASS__, 'add_templates'));
 }
 /**
  * Controller for all box ajax requests.
  */
 static function wp_ajax_p2p_box()
 {
     check_ajax_referer(P2P_BOX_NONCE, 'nonce');
     $ctype = p2p_type($_REQUEST['p2p_type']);
     if (!$ctype || !isset(self::$box_args[$ctype->name])) {
         die(0);
     }
     $post_type = get_post_type($_REQUEST['from']);
     if (!$post_type) {
         die(0);
     }
     $directed = $ctype->set_direction($_REQUEST['direction']);
     if (!$directed) {
         die(0);
     }
     $box = new P2P_Box(self::$box_args[$ctype->name], $directed, $post_type);
     if (!$box->check_capability()) {
         die(-1);
     }
     $method = 'ajax_' . $_REQUEST['subaction'];
     $box->{$method}();
 }