Beispiel #1
0
 /**
  * Register the routes for the objects of the controller.
  *
  * @since 0.2.0
  */
 public function register_routes()
 {
     $namespace = util::get_namespace();
     register_rest_route($namespace, '/products', array('methods' => \WP_REST_Server::READABLE, 'callback' => array($this, 'get_items'), 'permission_callback' => array($this, 'get_items_permissions_check'), 'args' => array('plugin' => array('default' => 'edd', 'sanitize_callback' => array($this, 'strip_tags')))));
     register_rest_route($namespace, '/products/price/(?P<id>[\\d]+)', array('methods' => \WP_REST_Server::READABLE, 'callback' => array($this, 'get_price'), 'permission_callback' => array($this, 'get_items_permissions_check'), 'args' => array('plugin' => array('default' => 'edd', 'sanitize_callback' => array($this, 'strip_tags')))));
     register_rest_route($namespace, '/products/plugins', array('methods' => \WP_REST_Server::READABLE, 'callback' => array($this, 'get_plugins'), 'permission_callback' => array($this, 'get_items_permissions_check'), 'args' => array('context' => array('default' => 'select-options'))));
 }
Beispiel #2
0
 /**
  * Verify sessions nonce
  *
  * @since 0.3.0
  *
  * @param \WP_REST_Request $request Full data about the request.
  *
  * @return \WP_Error|\WP_REST_Response
  */
 public function verify_session_nonce($request)
 {
     return true;
     $allowed = util::verify_session_nonce($request);
     return (bool) $allowed;
 }
Beispiel #3
0
 /**
  * Data needed in app
  *
  * @since 0.2.0
  *
  * @access protected
  *
  * @return array
  */
 protected function vars()
 {
     return array('api' => esc_url_raw(util::get_url()), 'nonce' => wp_create_nonce('wp_rest'), 'partials' => esc_url_raw(INGOT_URL . 'assets/admin/partials/'), 'spinner_url' => trailingslashit(INGOT_URL) . 'assets/img/loading.gif', 'edd_active' => esc_attr(ingot_is_edd_active()), 'woo_active' => esc_attr(ingot_is_woo_active()), 'price_tests_enabled' => esc_attr(ingot_enable_price_testing()), 'click_type_options' => types::allowed_click_types(true), 'price_type_options' => types::allowed_price_types(), 'destinations' => \ingot\testing\tests\click\destination\types::destination_types(true, true), 'dev_mode' => INGOT_DEV_MODE);
 }
Beispiel #4
0
 /**
  * Data to be localize as INGOT_UI
  *
  * @return array
  */
 public static function js_vars()
 {
     $session = self::$instance->current_session_data;
     unset($session['session']);
     $vars = array('api_url' => esc_url_raw(util::get_url()), 'nonce' => wp_create_nonce('wp_rest'), 'session_nonce' => wp_create_nonce('ingot_session'), 'session' => $session);
     return $vars;
 }
Beispiel #5
0
 /**
  * Test that this route is registered properly
  *
  * @since 0.2.0
  *
  * @group rest
  * @group settings_rest
  * @group group_rest
  * @group tracking_rest
  * @group session_rest
  * @group variant_rest
  */
 public function test_register_route()
 {
     $routes = $this->server->get_routes();
     $this->assertArrayHasKey('/' . \ingot\testing\api\rest\util::get_namespace() . '/' . $this->route_name, $routes, get_class($this));
     $this->assertArrayHasKey($this->namespaced_route, $routes, get_class($this));
 }
Beispiel #6
0
 /**
  * Make namespace for routes
  *
  * @since 0.0.8
  *
  * @access protected
  *
  * @return string
  */
 protected function make_namespace()
 {
     return util::get_namespace();
 }
Beispiel #7
0
 /**
  * Data to be localize as INGOT_UI
  *
  * @return array
  */
 public static function js_vars()
 {
     $vars = array('api_url' => esc_url_raw(util::get_url()), 'nonce' => wp_create_nonce('wp_rest'), 'session_nonce' => wp_create_nonce('ingot_session'), 'session' => \ingot\testing\object\session::instance()->get_session_info());
     return $vars;
 }