Changeset 1690123
- Timestamp:
- 07/03/2017 10:22:59 PM (9 years ago)
- Location:
- admin-ajax-php-no-thank-you
- Files:
-
- 3 added
- 8 edited
-
assets/icon-128x128.png (added)
-
assets/icon-256x256.png (added)
-
trunk/_plugin.php (modified) (1 diff)
-
trunk/autoload.php (added)
-
trunk/composer.json (modified) (1 diff)
-
trunk/functions.php (modified) (1 diff)
-
trunk/index.php (modified) (2 diffs)
-
trunk/lib/Admin_Ajax/Admin.php (modified) (1 diff)
-
trunk/lib/Admin_Ajax/No_Thank_You.php (modified) (2 diffs)
-
trunk/public/admin/options-general.js (modified) (2 diffs)
-
trunk/views/admin/options-general-enabled.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
admin-ajax-php-no-thank-you/trunk/_plugin.php
r1688551 r1690123 2 2 /* 3 3 Plugin Name: admin-ajax.php, no thank you! 4 Author: pinecone-dot-website, postpostmodern 5 Author URI: https://rack.and.pinecone.website/ 6 Description: Changes the wp-admin/admin-ajax.php endpoint to /ajax/ 7 Domain Path: /lang 4 8 Plugin URI: https://github.com/pinecone-dot-website/admin-ajax-dot-php-no-thank-you 5 Description: Changes the wp-admin/admin-ajax.php endpoint to /ajax/6 Author: pinecone-dot-website, postpostmodern7 9 Text Domain: 8 Domain Path: /lang 9 Version: 0.4.0 10 Author URI: https://rack.and.pinecone.website/ 10 Version: 0.5.0 11 11 */ 12 12 -
admin-ajax-php-no-thank-you/trunk/composer.json
r1688498 r1690123 14 14 ], 15 15 "psr-4": { 16 "Admin_Ajax\\": "lib/Admin_Ajax "16 "Admin_Ajax\\": "lib/Admin_Ajax/" 17 17 } 18 18 }, -
admin-ajax-php-no-thank-you/trunk/functions.php
r1688535 r1690123 35 35 return $data['Version']; 36 36 } 37 38 /** 39 * 40 */ 41 function wp_ajax_test() 42 { 43 $response = array( 44 'post' => $_POST 45 ); 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/index.php
r1688526 r1690123 3 3 namespace Admin_Ajax; 4 4 5 /** 6 * PSR-4 7 * @todo detect if composer autoload is being used 8 * @param string 9 */ 10 function autoload($class) 11 { 12 if (strpos($class, __NAMESPACE__) !== 0) { 13 return; 14 } 15 16 $file = __DIR__ .'/lib/'. str_replace('\\', '/', $class) . '.php'; 17 if (file_exists($file)) { 18 require $file; 19 } 5 if (!function_exists('Admin_Ajax\version')) { 6 require __DIR__.'/autoload.php'; 20 7 } 21 spl_autoload_register( __NAMESPACE__.'\autoload' ); 22 23 require_once __DIR__.'/functions.php'; 24 8 25 9 new No_Thank_You; 26 10 … … 28 12 new Admin; 29 13 } 30 31 add_action( 'wp_ajax_admin-ajax-test', function () {32 $response = array(33 'post' => $_POST34 );35 36 wp_send_json( $response );37 } ); -
admin-ajax-php-no-thank-you/trunk/lib/Admin_Ajax/Admin.php
r1688551 r1690123 51 51 public function description($args) 52 52 { 53 echo sprintf( '<pre>%s</pre>', version() ); 53 54 } 54 55 -
admin-ajax-php-no-thank-you/trunk/lib/Admin_Ajax/No_Thank_You.php
r1688551 r1690123 103 103 } 104 104 105 if ( !empty($parsed['query']) ){105 if (!empty($parsed['query'])) { 106 106 parse_str( $parsed['query'], $query_vars ); 107 107 $url = add_query_arg( $query_vars, $url ); … … 159 159 public function rest_api_init() 160 160 { 161 register_rest_route( 'wp/v2', '/admin-ajax', array( 161 $endpoint = array_filter( explode('/', self::$settings['endpoint']['rest-api']) ); 162 if (count($endpoint) < 3) { 163 return; 164 } 165 166 $namespace = implode( '/', array_slice($endpoint, 0, 2) ); 167 $route = implode( '/', array_slice($endpoint, 2) ); 168 169 register_rest_route( $namespace, $route, array( 162 170 'methods' => 'GET, POST', 163 171 'callback' => array($this, 'require_admin_ajax'), -
admin-ajax-php-no-thank-you/trunk/public/admin/options-general.js
r1688526 r1690123 22 22 'rand': rand 23 23 }, 24 'error': function (data) { 25 ajax_test_error() 26 }, 24 27 'method': 'post', 25 28 'success': function (data) { 26 29 if (typeof data.post == 'object' && data.post.rand == rand) { 27 $debugger.append('response correct!\n\n');30 ajax_test_success(); 28 31 } else { 29 $debugger.append('something is wrong!\n\n');32 ajax_test_error(); 30 33 } 31 34 }, … … 36 39 $this.html($link); 37 40 }); 41 42 function ajax_test_error() { 43 $debugger.append('something is wrong!\n\n'); 44 } 45 46 function ajax_test_success() { 47 $debugger.append('response correct!\n\n'); 48 } 38 49 })(jQuery); -
admin-ajax-php-no-thank-you/trunk/views/admin/options-general-enabled.php
r1688526 r1690123 15 15 <td> 16 16 <label>Rewrite endpoint</label> 17 <input type="text" value="<?php echo esc_attr($settings['endpoint']['rewrite']); ?>" name="admin_ajax_no_thank_you[endpoint][rewrite]" placeholder=" /ajax/">17 <input type="text" value="<?php echo esc_attr($settings['endpoint']['rewrite']); ?>" name="admin_ajax_no_thank_you[endpoint][rewrite]" placeholder="ajax"> 18 18 </td> 19 19 <td data-url="<?php echo esc_attr($endpoints['rewrite']); ?>"></td> … … 25 25 <td> 26 26 <label>REST API endpoint</label> 27 <input type="text" value="<?php echo esc_attr($settings['endpoint']['rest-api']); ?>" name="admin_ajax_no_thank_you[endpoint][rest-api]" placeholder=" /wp/v2/admin-ajax">27 <input type="text" value="<?php echo esc_attr($settings['endpoint']['rest-api']); ?>" name="admin_ajax_no_thank_you[endpoint][rest-api]" placeholder="wp/v2/admin-ajax"> 28 28 </td> 29 29 <td data-url="<?php echo esc_attr($endpoints['rest']); ?>"></td>
Note: See TracChangeset
for help on using the changeset viewer.