PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.7.9
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.7.9
2.7.9 2.7.8 2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 All 30 releases
← All changes | admin/ajax/snippet-library.php +26 -60 2.6.0 → 2.7.9 View file →
@@ -1,11 +1,9 @@
1 1 <?php
2 2 /**
3 3 * Ajax requests handler
4 4 *
5 - * @author Webcraftic <[email protected]>
6 - * @copyright (c) 2018 Webraftic Ltd
7 - * @version 1.0
5 + * @package Woody_Code_Snippets
8 6 */
9 7
10 8 // Exit if accessed directly
11 9 if ( ! defined( 'ABSPATH' ) ) {
@@ -15,27 +13,27 @@
15 13 /**
16 14 * Get snippet library table content
17 15 */
18 16 function wbcr_inp_ajax_get_snippet_library() {
19 - if ( ! WINP_Plugin::app()->currentUserCan() ) {
17 + if ( ! WINP_Plugin::app()->current_user_car() ) {
20 18 wp_die( - 1, 403 );
21 19 }
22 20
23 21 check_ajax_referer( 'winp-snippet-library', 'winp_nonce' );
24 22 ?>
25 - <div class="wrap">
26 - <form id="winp-snippet-library-list" method="get">
27 - <input type="hidden" name="page" value="<?php echo WINP_Plugin::app()->request->request( 'page', 1, true ); ?>"/>
28 - <input type="hidden" name="order" value="<?php echo WINP_Plugin::app()->request->request( 'order', 'asc', true ); ?>"/>
29 - <input type="hidden" name="orderby" value="<?php echo WINP_Plugin::app()->request->request( 'orderby', 'title', true ); ?>"/>
30 - <div id="winp-snippet-library-table" style="">
31 - <p><?php _e( 'Loading...', 'insert-php' ); ?></p>
23 + <div class="wrap">
24 + <form id="winp-snippet-library-list" method="get">
25 + <input type="hidden" name="page" value="<?php echo WINP_HTTP::request( 'page', 1, true ); ?>"/>
26 + <input type="hidden" name="order" value="<?php echo WINP_HTTP::request( 'order', 'asc', true ); ?>"/>
27 + <input type="hidden" name="orderby" value="<?php echo WINP_HTTP::request( 'orderby', 'title', true ); ?>"/>
28 + <div id="winp-snippet-library-table" style="">
29 + <p><?php _e( 'Loading snippets...', 'insert-php' ); ?></p>
32 30 <?php
33 31 wp_nonce_field( 'winp-ajax-custom-list-nonce', 'winp_ajax_custom_list_nonce' );
34 32 ?>
35 - </div>
36 - </form>
37 - </div>
33 + </div>
34 + </form>
35 + </div>
38 36 <?php
39 37 wp_die();
40 38 }
41 39
@@ -41,40 +39,20 @@
41 39
42 40 add_action( 'wp_ajax_winp_get_snippet_library', 'wbcr_inp_ajax_get_snippet_library' );
43 41
44 42 /**
45 - * Snippet synchronization
46 - */
47 -function wbcr_inp_ajax_snippet_synchronization() {
48 - if ( ! WINP_Plugin::app()->currentUserCan() ) {
49 - wp_die( - 1, 403 );
50 - }
51 -
52 - $snippet_id = WINP_Plugin::app()->request->post( 'snippet_id', 0, 'intval' );
53 - $snippet_name = WINP_Plugin::app()->request->post( 'snippet_name', '', true );
54 -
55 - check_ajax_referer( "wbcr_inp_save_snippet_{$snippet_id}_as_template" );
56 -
57 - $result = WINP_Plugin::app()->get_api_object()->synchronization( $snippet_id, $snippet_name );
58 -
59 - exit( $result );
60 -}
61 -
62 -add_action( 'wp_ajax_winp_snippet_synchronization', 'wbcr_inp_ajax_snippet_synchronization' );
63 -
64 -/**
65 43 * Snippet create from library
66 44 */
67 45 function wbcr_inp_ajax_snippet_create() {
68 - if ( ! WINP_Plugin::app()->currentUserCan() ) {
46 + if ( ! WINP_Plugin::app()->current_user_car() ) {
69 47 wp_die( - 1, 403 );
70 48 }
71 49
72 50 check_ajax_referer( 'winp-ajax-custom-list-nonce', 'winp_ajax_custom_list_nonce' );
73 51
74 - $snippet_id = WINP_Plugin::app()->request->post( 'snippet_id', 0, true );
75 - $post_id = WINP_Plugin::app()->request->post( 'post_id', 0, true );
76 - $common = WINP_Plugin::app()->request->post( 'common', 0 );
52 + $snippet_id = WINP_HTTP::post( 'snippet_id', 0, true );
53 + $post_id = WINP_HTTP::post( 'post_id', 0, true );
54 + $common = WINP_HTTP::post( 'common', 0 );
77 55 $result = WINP_Plugin::app()->get_api_object()->create_from_library( $snippet_id, $post_id, $common );
78 56
79 57 echo( $result );
80 58 exit();
@@ -85,13 +63,13 @@
85 63 /**
86 64 * Snippet delete from library
87 65 */
88 66 function wbcr_inp_ajax_snippet_delete() {
89 - if ( ! WINP_Plugin::app()->currentUserCan() ) {
67 + if ( ! WINP_Plugin::app()->current_user_car() ) {
90 68 wp_die( - 1, 403 );
91 69 }
92 70
93 - $snippet_id = WINP_Plugin::app()->request->post( 'snippet_id', 0, true );
71 + $snippet_id = WINP_HTTP::post( 'snippet_id', 0, true );
94 72
95 73 check_ajax_referer( 'winp-ajax-snippet-delete-' . $snippet_id, 'winp_ajax_snippet_delete_nonce' );
96 74
97 75 $result = WINP_Plugin::app()->get_api_object()->delete_snippet( $snippet_id );
@@ -105,9 +83,9 @@
105 83 /**
106 84 * Action wp_ajax for fetching the first time table structure
107 85 */
108 86 function wbcr_inp_ajax_sts_display_callback() {
109 - if ( ! WINP_Plugin::app()->currentUserCan() ) {
87 + if ( ! WINP_Plugin::app()->current_user_car() ) {
110 88 wp_die( - 1, 403 );
111 89 }
112 90
113 91 check_ajax_referer( 'winp-ajax-custom-list-nonce', 'winp_ajax_custom_list_nonce' );
@@ -120,28 +98,16 @@
120 98 $snippet_list_table->prepare_items();
121 99 ob_start();
122 100 $snippet_list_table->display();
123 101 $display = ob_get_clean();
124 - die( json_encode( [
125 - 'display' => $display,
126 - ] ) );
102 + die(
103 + json_encode(
104 + [
105 + 'display' => $display,
106 + ]
107 + )
108 + );
127 109 }
128 110
129 111 add_action( 'wp_ajax_winp_sts_display', 'wbcr_inp_ajax_sts_display_callback' );
130 112
131 -/**
132 - * Action wp_ajax for fetching ajax_response
133 - */
134 -function wbcr_inp_ajax_sts_history_callback() {
135 - if ( ! WINP_Plugin::app()->currentUserCan() ) {
136 - wp_die( - 1, 403 );
137 - }
138 113
139 - check_ajax_referer( 'winp-ajax-custom-list-nonce', 'winp_ajax_custom_list_nonce' );
140 -
141 - require_once WINP_PLUGIN_DIR . '/admin/includes/class.snippets.table.php';
142 -
143 - $snippet_list_table = new WINP_Snippet_Library_Table( true );
144 - $snippet_list_table->ajax_response();
145 -}
146 -
147 -add_action( 'wp_ajax_winp_fetch_sts_history', [ $this, 'wbcr_inp_ajax_sts_history_callback' ] );