PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.7.8
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.7.8
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 +113 -147 2.2.7 → 2.7.8 View file →
@@ -1,147 +1,113 @@
1 -<?php
2 -/**
3 - * Ajax requests handler
4 - *
5 - * @author Webcraftic <[email protected]>
6 - * @copyright (c) 2018 Webraftic Ltd
7 - * @version 1.0
8 - */
9 -
10 -// Exit if accessed directly
11 -if ( ! defined( 'ABSPATH' ) ) {
12 - exit;
13 -}
14 -
15 -/**
16 - * Get snippet library table content
17 - */
18 -function wbcr_inp_ajax_get_snippet_library() {
19 - if ( ! WINP_Plugin::app()->currentUserCan() ) {
20 - wp_die( - 1, 403 );
21 - }
22 -
23 - check_ajax_referer( 'winp-snippet-library', 'winp_nonce' );
24 - ?>
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>
32 - <?php
33 - wp_nonce_field( 'winp-ajax-custom-list-nonce', 'winp_ajax_custom_list_nonce' );
34 - ?>
35 - </div>
36 - </form>
37 - </div>
38 - <?php
39 - wp_die();
40 -}
41 -
42 -add_action( 'wp_ajax_winp_get_snippet_library', 'wbcr_inp_ajax_get_snippet_library' );
43 -
44 -/**
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 - * Snippet create from library
66 - */
67 -function wbcr_inp_ajax_snippet_create() {
68 - if ( ! WINP_Plugin::app()->currentUserCan() ) {
69 - wp_die( - 1, 403 );
70 - }
71 -
72 - check_ajax_referer( 'winp-ajax-custom-list-nonce', 'winp_ajax_custom_list_nonce' );
73 -
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 );
77 - $result = WINP_Plugin::app()->get_api_object()->create_from_library( $snippet_id, $post_id, $common );
78 -
79 - echo( $result );
80 - exit();
81 -}
82 -
83 -add_action( 'wp_ajax_winp_snippet_create', 'wbcr_inp_ajax_snippet_create' );
84 -
85 -/**
86 - * Snippet delete from library
87 - */
88 -function wbcr_inp_ajax_snippet_delete() {
89 - if ( ! WINP_Plugin::app()->currentUserCan() ) {
90 - wp_die( - 1, 403 );
91 - }
92 -
93 - $snippet_id = WINP_Plugin::app()->request->post( 'snippet_id', 0, true );
94 -
95 - check_ajax_referer( 'winp-ajax-snippet-delete-' . $snippet_id, 'winp_ajax_snippet_delete_nonce' );
96 -
97 - $result = WINP_Plugin::app()->get_api_object()->delete_snippet( $snippet_id );
98 -
99 - echo( $result );
100 - exit();
101 -}
102 -
103 -add_action( 'wp_ajax_winp_snippet_delete', 'wbcr_inp_ajax_snippet_delete' );
104 -
105 -/**
106 - * Action wp_ajax for fetching the first time table structure
107 - */
108 -function wbcr_inp_ajax_sts_display_callback() {
109 - if ( ! WINP_Plugin::app()->currentUserCan() ) {
110 - wp_die( - 1, 403 );
111 - }
112 -
113 - check_ajax_referer( 'winp-ajax-custom-list-nonce', 'winp_ajax_custom_list_nonce' );
114 -
115 - require_once( WINP_PLUGIN_DIR . '/admin/includes/class.snippets.table.php' );
116 -
117 - // Create an instance of our package class...
118 - $snippet_list_table = new WINP_Snippet_Library_Table( true );
119 - // Fetch, prepare, sort, and filter our data...
120 - $snippet_list_table->prepare_items();
121 - ob_start();
122 - $snippet_list_table->display();
123 - $display = ob_get_clean();
124 - die( json_encode( [
125 - 'display' => $display,
126 - ] ) );
127 -}
128 -
129 -add_action( 'wp_ajax_winp_sts_display', 'wbcr_inp_ajax_sts_display_callback' );
130 -
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 -
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' ] );
1 +<?php
2 +/**
3 + * Ajax requests handler
4 + *
5 + * @package Woody_Code_Snippets
6 + */
7 +
8 +// Exit if accessed directly
9 +if ( ! defined( 'ABSPATH' ) ) {
10 + exit;
11 +}
12 +
13 +/**
14 + * Get snippet library table content
15 + */
16 +function wbcr_inp_ajax_get_snippet_library() {
17 + if ( ! WINP_Plugin::app()->current_user_car() ) {
18 + wp_die( - 1, 403 );
19 + }
20 +
21 + check_ajax_referer( 'winp-snippet-library', 'winp_nonce' );
22 + ?>
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>
30 + <?php
31 + wp_nonce_field( 'winp-ajax-custom-list-nonce', 'winp_ajax_custom_list_nonce' );
32 + ?>
33 + </div>
34 + </form>
35 + </div>
36 + <?php
37 + wp_die();
38 +}
39 +
40 +add_action( 'wp_ajax_winp_get_snippet_library', 'wbcr_inp_ajax_get_snippet_library' );
41 +
42 +/**
43 + * Snippet create from library
44 + */
45 +function wbcr_inp_ajax_snippet_create() {
46 + if ( ! WINP_Plugin::app()->current_user_car() ) {
47 + wp_die( - 1, 403 );
48 + }
49 +
50 + check_ajax_referer( 'winp-ajax-custom-list-nonce', 'winp_ajax_custom_list_nonce' );
51 +
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 );
55 + $result = WINP_Plugin::app()->get_api_object()->create_from_library( $snippet_id, $post_id, $common );
56 +
57 + echo( $result );
58 + exit();
59 +}
60 +
61 +add_action( 'wp_ajax_winp_snippet_create', 'wbcr_inp_ajax_snippet_create' );
62 +
63 +/**
64 + * Snippet delete from library
65 + */
66 +function wbcr_inp_ajax_snippet_delete() {
67 + if ( ! WINP_Plugin::app()->current_user_car() ) {
68 + wp_die( - 1, 403 );
69 + }
70 +
71 + $snippet_id = WINP_HTTP::post( 'snippet_id', 0, true );
72 +
73 + check_ajax_referer( 'winp-ajax-snippet-delete-' . $snippet_id, 'winp_ajax_snippet_delete_nonce' );
74 +
75 + $result = WINP_Plugin::app()->get_api_object()->delete_snippet( $snippet_id );
76 +
77 + echo( $result );
78 + exit();
79 +}
80 +
81 +add_action( 'wp_ajax_winp_snippet_delete', 'wbcr_inp_ajax_snippet_delete' );
82 +
83 +/**
84 + * Action wp_ajax for fetching the first time table structure
85 + */
86 +function wbcr_inp_ajax_sts_display_callback() {
87 + if ( ! WINP_Plugin::app()->current_user_car() ) {
88 + wp_die( - 1, 403 );
89 + }
90 +
91 + check_ajax_referer( 'winp-ajax-custom-list-nonce', 'winp_ajax_custom_list_nonce' );
92 +
93 + require_once WINP_PLUGIN_DIR . '/admin/includes/class.snippets.table.php';
94 +
95 + // Create an instance of our package class...
96 + $snippet_list_table = new WINP_Snippet_Library_Table( true );
97 + // Fetch, prepare, sort, and filter our data...
98 + $snippet_list_table->prepare_items();
99 + ob_start();
100 + $snippet_list_table->display();
101 + $display = ob_get_clean();
102 + die(
103 + json_encode(
104 + [
105 + 'display' => $display,
106 + ]
107 + )
108 + );
109 +}
110 +
111 +add_action( 'wp_ajax_winp_sts_display', 'wbcr_inp_ajax_sts_display_callback' );
112 +
113 +