Changeset 1742242
- Timestamp:
- 10/06/2017 03:20:51 PM (8 years ago)
- Location:
- admin-ajax-php-no-thank-you/trunk
- Files:
-
- 7 edited
-
_plugin.php (modified) (1 diff)
-
functions.php (modified) (2 diffs)
-
lib/Admin_Ajax/Admin.php (modified) (7 diffs)
-
lib/Admin_Ajax/No_Thank_You.php (modified) (4 diffs)
-
vendor/autoload.php (modified) (1 diff)
-
vendor/composer/autoload_real.php (modified) (5 diffs)
-
vendor/composer/autoload_static.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
admin-ajax-php-no-thank-you/trunk/_plugin.php
r1741843 r1742242 8 8 Domain Path: /lang 9 9 Text Domain: 10 Version: 0.6. 110 Version: 0.6.3 11 11 */ 12 12 -
admin-ajax-php-no-thank-you/trunk/functions.php
r1690123 r1742242 8 8 * @param object|array 9 9 */ 10 function render($_template, $vars = array())10 function render($_template, $vars = []) 11 11 { 12 12 $_template_file = sprintf( '%s/views/%s.php', __DIR__, $_template ); … … 35 35 return $data['Version']; 36 36 } 37 38 /**39 *40 */41 function wp_ajax_test()42 {43 $response = array(44 'post' => $_POST45 );46 47 wp_send_json( $response );48 }49 add_action( 'wp_ajax_admin-ajax-test', __NAMESPACE__.'\wp_ajax_test' );50 //add_action( 'wp_ajax_nopriv_admin-ajax-test', __NAMESPACE__.'\wp_ajax_test' ); -
admin-ajax-php-no-thank-you/trunk/lib/Admin_Ajax/Admin.php
r1702468 r1742242 7 7 public function __construct() 8 8 { 9 add_filter( 'admin_footer_text', array($this, 'admin_footer_text'));10 add_action( 'admin_menu', array($this, 'admin_menu'));11 add_filter( 'plugin_action_links_admin-ajax-dot-php-no-thank-you/_plugin.php', array($this, 'plugin_action_links'));9 add_filter( 'admin_footer_text', [$this, 'admin_footer_text'] ); 10 add_action( 'admin_menu', [$this, 'admin_menu'] ); 11 add_filter( 'plugin_action_links_admin-ajax-dot-php-no-thank-you/_plugin.php', [$this, 'plugin_action_links'] ); 12 12 } 13 13 … … 19 19 public function admin_footer_text($original = '') 20 20 { 21 return render( 'admin/options-general_footer', array(21 return render( 'admin/options-general_footer', [ 22 22 'version' => version() 23 ));23 ] ); 24 24 } 25 25 … … 36 36 'manage_options', 37 37 'admin-ajax.php-no-thank-you', 38 array($this, 'render_main')38 [$this, 'render_main'] 39 39 ); 40 40 … … 42 42 'admin_ajax_no_thank_you_settings_section', 43 43 '', // subhead 44 array($this,'description'),44 [$this,'description'], 45 45 'admin_ajax_no_thank_you' 46 46 ); … … 49 49 'admin_ajax_no_thank_you-endpoints', 50 50 'Endpoints', 51 array($this, 'render_enabled'),51 [$this, 'render_enabled'], 52 52 'admin_ajax_no_thank_you', 53 53 'admin_ajax_no_thank_you_settings_section' 54 54 ); 55 55 56 register_setting( 'admin_ajax_no_thank_you', 'admin_ajax_no_thank_you', array($this,'save_setting'));56 register_setting( 'admin_ajax_no_thank_you', 'admin_ajax_no_thank_you', [$this,'save_setting'] ); 57 57 } 58 58 … … 88 88 $settings = No_Thank_You::get_settings(); 89 89 90 echo render( 'admin/options-general-enabled', array(91 'endpoints' => array(90 echo render( 'admin/options-general-enabled', [ 91 'endpoints' => [ 92 92 'rest' => No_Thank_You::get_endpoint_rest(), 93 93 'rewrite' => No_Thank_You::get_endpoint_rewrite() 94 ),94 ], 95 95 'settings' => $settings 96 ));96 ] ); 97 97 } 98 98 … … 102 102 public function render_main() 103 103 { 104 wp_enqueue_script( 'taxonomy-taxi', plugins_url('public/admin/options-general.js', dirname(__DIR__)), array(), version(), 'all' );104 wp_enqueue_script( 'taxonomy-taxi', plugins_url('public/admin/options-general.js', dirname(__DIR__)), [], version(), 'all' ); 105 105 echo render( 'admin/options-general' ); 106 106 } -
admin-ajax-php-no-thank-you/trunk/lib/Admin_Ajax/No_Thank_You.php
r1702468 r1742242 11 11 self::load_settings(); 12 12 13 add_filter( 'admin_url', array($this, 'rewrite_ajax_admin_url'), 10, 3 ); 14 add_action( 'rest_api_init', array($this, 'rest_api_init') ); 15 add_filter( 'pre_get_posts', array($this, 'rewrite_ajax_pre_get_posts'), 1, 1 ); 16 add_filter( 'query_vars', array($this, 'rewrite_ajax_query_vars'), 10, 1 ); 17 add_filter( 'root_rewrite_rules', array($this, 'rewrite_ajax_root_rewrite_rules'), 10, 1 ); 13 add_filter( 'admin_url', [$this, 'rewrite_ajax_admin_url'], 10, 3 ); 14 add_action( 'rest_api_init', [$this, 'rest_api_init'] ); 15 add_filter( 'pre_get_posts', [$this, 'rewrite_ajax_pre_get_posts'], 1, 1 ); 16 add_filter( 'query_vars', [$this, 'rewrite_ajax_query_vars'], 10, 1 ); 17 add_filter( 'root_rewrite_rules', [$this, 'rewrite_ajax_root_rewrite_rules'], 10, 1 ); 18 19 // testing 20 add_action( 'wp_ajax_admin-ajax-test', [$this, 'wp_ajax_test'] ); 21 //add_action( 'wp_ajax_nopriv_admin-ajax-test', [$this, 'wp_ajax_test'] ); 18 22 } 19 23 … … 34 38 { 35 39 $url = get_rest_url( $blog_id, self::$settings['endpoint']['rest-api'] ); 36 $url = add_query_arg( array(40 $url = add_query_arg( [ 37 41 '_wpnonce' => wp_create_nonce( 'wp_rest' ) 38 ), $url );42 ], $url ); 39 43 40 44 return $url; … … 56 60 public static function load_settings() 57 61 { 58 $defaults = array(62 $defaults = [ 59 63 'default' => '', 60 'enabled' => array(),61 'endpoint' => array(64 'enabled' => [], 65 'endpoint' => [ 62 66 'rewrite' => 'ajax', 63 67 'rest-api' => 'wp/v2/admin-ajax' 64 )65 );68 ] 69 ]; 66 70 67 $settings = get_option( 'admin_ajax_no_thank_you', array());71 $settings = get_option( 'admin_ajax_no_thank_you', [] ); 68 72 69 73 self::$settings = array_merge( $defaults, $settings ); … … 168 172 $route = implode( '/', array_slice($endpoint, 2) ); 169 173 170 register_rest_route( $namespace, $route, array(174 register_rest_route( $namespace, $route, [ 171 175 'methods' => 'GET, POST', 172 'callback' => array($this, 'require_admin_ajax'), 173 ) ); 176 'callback' => [$this, 'require_admin_ajax'], 177 ] ); 178 } 179 180 /** 181 * returns post data in json 182 * used for testing wp-admin/options-general.php?page=admin-ajax.php-no-thank-you 183 */ 184 function wp_ajax_test() 185 { 186 $response = [ 187 'post' => $_POST 188 ]; 189 190 wp_send_json( $response ); 174 191 } 175 192 } -
admin-ajax-php-no-thank-you/trunk/vendor/autoload.php
r1741843 r1742242 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit d31aed9946977beb7ec1dd48403ce777::getLoader();7 return ComposerAutoloaderInitbb5fee69188b1e5af9cbd549cbf21d3c::getLoader(); -
admin-ajax-php-no-thank-you/trunk/vendor/composer/autoload_real.php
r1741843 r1742242 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit d31aed9946977beb7ec1dd48403ce7775 class ComposerAutoloaderInitbb5fee69188b1e5af9cbd549cbf21d3c 6 6 { 7 7 private static $loader; … … 20 20 } 21 21 22 spl_autoload_register(array('ComposerAutoloaderInit d31aed9946977beb7ec1dd48403ce777', 'loadClassLoader'), true, true);22 spl_autoload_register(array('ComposerAutoloaderInitbb5fee69188b1e5af9cbd549cbf21d3c', 'loadClassLoader'), true, true); 23 23 self::$loader = $loader = new \Composer\Autoload\ClassLoader(); 24 spl_autoload_unregister(array('ComposerAutoloaderInit d31aed9946977beb7ec1dd48403ce777', 'loadClassLoader'));24 spl_autoload_unregister(array('ComposerAutoloaderInitbb5fee69188b1e5af9cbd549cbf21d3c', 'loadClassLoader')); 25 25 26 26 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 28 28 require_once __DIR__ . '/autoload_static.php'; 29 29 30 call_user_func(\Composer\Autoload\ComposerStaticInit d31aed9946977beb7ec1dd48403ce777::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInitbb5fee69188b1e5af9cbd549cbf21d3c::getInitializer($loader)); 31 31 } else { 32 32 $map = require __DIR__ . '/autoload_namespaces.php'; … … 49 49 50 50 if ($useStaticLoader) { 51 $includeFiles = Composer\Autoload\ComposerStaticInit d31aed9946977beb7ec1dd48403ce777::$files;51 $includeFiles = Composer\Autoload\ComposerStaticInitbb5fee69188b1e5af9cbd549cbf21d3c::$files; 52 52 } else { 53 53 $includeFiles = require __DIR__ . '/autoload_files.php'; 54 54 } 55 55 foreach ($includeFiles as $fileIdentifier => $file) { 56 composerRequire d31aed9946977beb7ec1dd48403ce777($fileIdentifier, $file);56 composerRequirebb5fee69188b1e5af9cbd549cbf21d3c($fileIdentifier, $file); 57 57 } 58 58 … … 61 61 } 62 62 63 function composerRequire d31aed9946977beb7ec1dd48403ce777($fileIdentifier, $file)63 function composerRequirebb5fee69188b1e5af9cbd549cbf21d3c($fileIdentifier, $file) 64 64 { 65 65 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
admin-ajax-php-no-thank-you/trunk/vendor/composer/autoload_static.php
r1741843 r1742242 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit d31aed9946977beb7ec1dd48403ce7777 class ComposerStaticInitbb5fee69188b1e5af9cbd549cbf21d3c 8 8 { 9 9 public static $files = array ( … … 28 28 { 29 29 return \Closure::bind(function () use ($loader) { 30 $loader->prefixLengthsPsr4 = ComposerStaticInit d31aed9946977beb7ec1dd48403ce777::$prefixLengthsPsr4;31 $loader->prefixDirsPsr4 = ComposerStaticInit d31aed9946977beb7ec1dd48403ce777::$prefixDirsPsr4;30 $loader->prefixLengthsPsr4 = ComposerStaticInitbb5fee69188b1e5af9cbd549cbf21d3c::$prefixLengthsPsr4; 31 $loader->prefixDirsPsr4 = ComposerStaticInitbb5fee69188b1e5af9cbd549cbf21d3c::$prefixDirsPsr4; 32 32 33 33 }, null, ClassLoader::class);
Note: See TracChangeset
for help on using the changeset viewer.