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 / types / snippets-post-types.php

snippets-post-types.php in Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts 2.3.1, at admin/types/snippets-post-types.php

141 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Php Snippets Type
5 * Declaration for custom post type of Php code snippets
6 *
7 * @link http://codex.wordpress.org/Post_Types
8 */
9
10 // Exit if accessed directly
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 class WINP_SnippetsType extends Wbcr_FactoryTypes410_Type {
16
17 /**
18 * Custom post name.
19 *
20 * @var string
21 */
22 //public $name = 'wbcr-scrapes';
23
24 /**
25 * Template that defines a set of type options.
26 * Allowed values: public, private, internal.
27 *
28 * @var string
29 */
30 public $template = 'private';
31
32 /**
33 * Capabilities for roles that have access to manage the type.
34 *
35 * @link http://codex.wordpress.org/Roles_and_Capabilities
36 * @var array
37 */
38 public $capabilities = [ 'administrator' ];
39
40 /**
41 * @param Wbcr_Factory422_Plugin $plugin
42 */
43 function __construct( Wbcr_Factory422_Plugin $plugin ) {
44 $this->name = WINP_SNIPPETS_POST_TYPE;
45 $this->plural_title = __( 'Woody snippets', 'insert-php' );
46 $this->singular_title = __( 'Woody snippets', 'insert-php' );
47
48 parent::__construct( $plugin );
49
50 add_action( 'admin_head', [ $this, 'print_left_menu_styles' ] );
51 }
52
53 /**
54 * Prints styles for Woody add snippets menu
55 */
56 public function print_left_menu_styles() {
57 ?>
58 <!-- Woody ad snippets -->
59 <style>
60 #menu-posts-wbcr-snippets .wp-menu-open .wp-menu-name {
61 background: #242525;
62 }
63 </style>
64 <!-- /Woody ad snippets -->
65 <?php
66 }
67
68 /**
69 * Type configurator.
70 */
71 public function configure() {
72 $plural_name = $this->plural_title;
73 $singular_name = $this->singular_title;
74
75 $labels = [
76 'singular_name' => $this->singular_title,
77 'name' => $this->plural_title,
78 'all_items' => sprintf( __( 'Snippets', 'insert-php' ), $plural_name ),
79 'add_new' => sprintf( __( '+ Add snippet', 'insert-php' ), $singular_name ),
80 'add_new_item' => sprintf( __( 'Add new', 'insert-php' ), $singular_name ),
81 'edit' => sprintf( __( 'Edit', 'insert-php' ) ),
82 'edit_item' => sprintf( __( 'Edit snippet', 'insert-php' ), $singular_name ),
83 'new_item' => sprintf( __( 'New snippet', 'insert-php' ), $singular_name ),
84 'view' => sprintf( __( 'View', 'factory' ) ),
85 'view_item' => sprintf( __( 'View snippet', 'insert-php' ), $singular_name ),
86 'search_items' => sprintf( __( 'Search snippets', 'insert-php' ), $plural_name ),
87 'not_found' => sprintf( __( 'Snippet is not found', 'insert-php' ), $plural_name ),
88 'not_found_in_trash' => sprintf( __( 'Snippt is not found in trash', 'insert-php' ), $plural_name ),
89 'parent' => sprintf( __( 'Parent snippet', 'insert-php' ), $plural_name )
90 ];
91
92 $this->options['labels'] = apply_filters( 'wbcr_inp_items_lables', $labels );
93 $this->options['can_export'] = WINP_Plugin::app()->get_api_object()->is_key() ? true : false;
94
95 $parameters = [ 'title', 'revisions' ];
96 $snippet_type = WINP_Helper::get_snippet_type();
97 if ( $snippet_type === WINP_SNIPPET_TYPE_TEXT ) {
98 $parameters[] = 'editor';
99 }
100 $this->options['supports'] = apply_filters( 'wbcr_inp_items_supports', $parameters );
101
102 /**
103 * Menu
104 */
105
106 $this->menu->icon = WINP_PLUGIN_URL . '/admin/assets/img/menu-icon-4.png';
107
108 /**
109 * View table
110 */
111
112 $this->view_table = 'WINP_SnippetsViewTable';
113
114 /**
115 * Scripts & styles
116 */
117
118 $this->scripts->request( [ 'jquery', 'jquery-effects-highlight', 'jquery-effects-slide' ] );
119
120 $this->scripts->request( [
121 'bootstrap.datepicker',
122 'control.checkbox',
123 'control.dropdown',
124 'control.list',
125 'bootstrap.tooltip',
126 'bootstrap.modal',
127 ], 'bootstrap' );
128
129 $this->styles->request( [
130 'bootstrap.core',
131 'bootstrap.datepicker',
132 'bootstrap.form-group',
133 'bootstrap.form-metabox',
134 'bootstrap.wp-editor',
135 'bootstrap.separator',
136 'control.checkbox',
137 'control.dropdown',
138 'control.list',
139 ], 'bootstrap' );
140 }
141 }