PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.3.1
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.3.1
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 2.6.1 2.7.0 All 28 releases
insert-php / admin / pages / snippet-library.php

snippet-library.php in Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts 2.3.1, at admin/pages/snippet-library.php

152 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * This class is implemented page: snippet library
4 *
5 * @author Webcraftic <wordpress.webraftic@gmail.com>
6 * @copyright (c) 2019, OnePress Ltd
7 *s
8 * @package core
9 * @since 1.0.0
10 */
11
12 // Exit if accessed directly
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Common Settings
19 */
20 class WINP_SnippetLibraryPage extends WINP_Page {
21
22 /**
23 * @param Wbcr_Factory422_Plugin $plugin
24 */
25 public function __construct( Wbcr_Factory422_Plugin $plugin ) {
26 $this->menu_post_type = WINP_SNIPPETS_POST_TYPE;
27
28 $this->id = 'snippet-library';
29 $this->menu_title = __( 'Snippets library', 'insert-php' );
30
31 parent::__construct( $plugin );
32
33 $this->plugin = $plugin;
34
35 require_once( WINP_PLUGIN_DIR . '/admin/includes/class.snippets.table.php' );
36 }
37
38 /**
39 * Assets
40 *
41 * @param $scripts
42 * @param $styles
43 */
44 public function assets( $scripts, $styles ) {
45 $this->scripts->request( 'jquery' );
46
47 $this->styles->request(
48 array(
49 'bootstrap.core',
50 ),
51 'bootstrap'
52 );
53
54 $this->styles->add( WINP_PLUGIN_URL . '/admin/assets/css/snippets-table.css' );
55
56 wp_enqueue_script( 'winp-snippet-library', WINP_PLUGIN_URL . '/admin/assets/js/snippet-library.js' );
57 wp_localize_script(
58 'winp-snippet-library',
59 'winp_snippet_library',
60 array(
61 'is_import' => __( 'Import snippet?', 'insert-php' ),
62 'is_delete' => __( 'Delete snippet?', 'insert-php' ),
63 'import_failed' => __( 'An error occurred during import', 'insert-php' ),
64 'delete_failed' => __( 'An error occurred during delete', 'insert-php' ),
65 )
66 );
67 }
68
69 /**
70 * Render html part with snippets list
71 *
72 * @param $common
73 */
74 public function render_html( $common ) {
75 // Create an instance of our package class...
76 $snippet_list_table = new WINP_Snippet_Library_Table();
77
78 $is_pro = $is_pro = WINP_Plugin::app()->get_api_object()->is_key();
79 if ( $is_pro ) : ?>
80 <!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
81 <form id="winp-snippet-library" method="get">
82 <!-- For plugins, we also need to ensure that the form posts back to our current page -->
83 <input type="hidden" name="page" value="<?php echo WINP_Plugin::app()->request->request( 'page', 1 ); ?>"/>
84 <!-- Now we can render the completed list table -->
85 <?php
86 $snippet_list_table->prepare_items( $common );
87 $snippet_list_table->display();
88 ?>
89 </form>
90
91 <?php wp_nonce_field( 'winp-snippet-library', 'winp-snippet-library-nonce' ); ?>
92 <?php else: ?>
93 <div class="winp-more-padding"></div>
94 <div class="row">
95 <div class="col-md-2 col-lg-4">&nbsp;</div>
96 <div class="col-sm-12 col-md-8 col-lg-4" style="text-align: center">
97 <p class="winp-icon"><span class="dashicons dashicons-category"></span></p>
98 <?php if ( $common ) : ?>
99 <p class="winp-header-modal"><?php _e('Snippets Library [Premium]', 'insert-php') ?></p>
100 <p class="winp-title-modal"><?php _e('Here you see all of your snippet templates. We’ve gathered the frequently used snippets so you can use them in your projects. Snippet templates help to implement your ideas faster without wasting time on searching and studying PHP code. The feature is available in the premium version only.', 'insert-php') ?></p>
101 <?php else: ?>
102 <p class="winp-header-modal"><?php _e('My Templates [Premium]', 'insert-php') ?></p>
103 <p class="winp-title-modal"><?php _e('Whenever you or someone from your team save snippets as templates on any website, they go to this section. Our remote server provides snippet synchronization. Thus, snippet templates are always available without extra import/export. The feature is available in the premium version only.', 'insert-php') ?></p>
104 <?php endif; ?>
105 <?php WINP_Helper::get_purchase_button() ?>
106 </div>
107 <div class="col-md-2 col-lg-4">&nbsp;</div>
108 </div>
109 <?php endif;
110 }
111
112 /**
113 * Prints the contents of the page.
114 */
115 public function indexAction() {
116 $my_snippets_tab = true;
117 $library_tab = false;
118 $my_snippets_url = remove_query_arg( array( 'tab' ) );
119 $library_url = add_query_arg( 'tab', 'library', $my_snippets_url );
120
121 if ( WINP_Plugin::app()->request->get( 'tab' ) == 'library' ) {
122 $my_snippets_tab = false;
123 $library_tab = true;
124 } ?>
125 <div class="wrap">
126 <div class="winp-snippet-library">
127 <h3><?php _e( 'Snippets library', 'insert-php' ); ?></h3>
128
129 <div class="nav-tab-wrapper">
130 <a href="<?php echo $my_snippets_url; ?>" class="nav-tab<?php echo( $my_snippets_tab ? ' nav-tab-active' : '' ); ?>">
131 <?php _e( 'My snippets', 'insert-php' ); ?>
132 </a>
133 <a href="<?php echo $library_url; ?>" class="nav-tab<?php echo( $library_tab ? ' nav-tab-active' : '' ); ?>">
134 <?php _e( 'Snippets library', 'insert-php' ); ?>
135 </a>
136 </div>
137
138 <?php if ( $library_tab ) : ?>
139 <div id="tab1">
140 <?php $this->render_html( true ); ?>
141 </div>
142 <?php else: ?>
143 <div id="tab2">
144 <?php $this->render_html( false ); ?>
145 </div>
146 <?php endif; ?>
147 </div>
148 </div>
149 <?php
150 }
151 }
152