PluginProbe
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More / 1.1.2
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More v1.1.2
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.10 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 47 releases
content-control / classes / Admin / Assets.php

Assets.php in Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More 1.1.2, at classes/Admin/Assets.php

150 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace JP\CC\Admin;
5
6 use JP_Content_Control;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12
13 class Assets {
14
15 public static function init() {
16 add_action( 'admin_enqueue_scripts', array( __CLASS__, 'scripts_styles' ) );
17 }
18
19 public static function scripts_styles( $hook ) {
20 global $post_type;
21
22 // Use minified libraries if SCRIPT_DEBUG is turned off
23 $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
24
25 if ( $hook == 'widgets.php' ) {
26 wp_enqueue_style( 'jpcc-widget-editor', JP_Content_Control::$URL . 'assets/styles/widget-editor' . $suffix . '.css', null, JP_Content_Control::$VER, false );
27 wp_enqueue_script( 'jpcc-widget-editor', JP_Content_Control::$URL . 'assets/scripts/widget-editor' . $suffix . '.js', array( 'jquery' ), JP_Content_Control::$VER, true );
28 }
29
30 if ( $hook == 'settings_page_jp-cc-settings' ) {
31
32 if ( Settings::active_tab() == 'restrictions' ) {
33 add_action( 'admin_footer', array( __CLASS__, 'js_wp_editor' ) );
34 }
35
36 add_action( 'admin_footer', array( '\\JP\CC\Admin\Footer_Templates', 'fields' ) );
37 add_action( 'admin_footer', array( '\\JP\CC\Admin\Footer_Templates', 'helpers' ) );
38 add_action( 'admin_footer', array( '\\JP\CC\Admin\Footer_Templates', 'restrictions' ) );
39 add_action( 'admin_footer', array( '\\JP\CC\Admin\Footer_Templates', 'conditions_editor' ) );
40
41
42 wp_enqueue_style( 'jpcc-settings-page', JP_Content_Control::$URL . 'assets/styles/settings-page' . $suffix . '.css', array( 'editor-buttons' ), JP_Content_Control::$VER, false );
43 wp_enqueue_script( 'jpcc-settings-page', JP_Content_Control::$URL . 'assets/scripts/settings-page' . $suffix . '.js', array(
44 'jquery',
45 'underscore',
46 'wp-util',
47 'wplink',
48 'jquery-ui-sortable',
49 ), JP_Content_Control::$VER, true );
50
51 wp_localize_script( 'jpcc-settings-page', 'jp_cc_vars', array(
52 'nonce' => wp_create_nonce( 'jp-cc-admin-nonce' ),
53 'I10n' => array(
54 'restrictions' => array(
55 'confirm_remove' => __( 'Are you sure you want to delete this restriction?', 'content-control' ),
56 ),
57 'restriction_modal' => array(
58 'title' => __( 'Restriction Editor', 'content-control' ),
59 'description' => __( 'Use this to modify a restrictions settings.', 'content-control' ),
60 ),
61 'conditions' => array(
62 'not_operand' => array(
63 'is' => __( 'Is', 'content-control' ),
64 'not' => __( 'Not', 'content-control' ),
65 ),
66 ),
67 'save' => __( 'Save', 'content-control' ),
68 'cancel' => __( 'Cancel', 'content-control' ),
69 'add' => __( 'Add', 'content-control' ),
70 'update' => __( 'Update', 'content-control' ),
71 ),
72 ) );
73
74 }
75
76 }
77
78
79 /*
80 * JavaScript Wordpress editor
81 * Author: Ante Primorac
82 * Author URI: http://anteprimorac.from.hr
83 * Version: 1.1
84 * License:
85 * Copyright (c) 2013 Ante Primorac
86 * Permission is hereby granted, free of charge, to any person obtaining a copy
87 * of this software and associated documentation files (the "Software"), to deal
88 * in the Software without restriction, including without limitation the rights
89 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
90 * copies of the Software, and to permit persons to whom the Software is
91 * furnished to do so, subject to the following conditions:
92 *
93 * The above copyright notice and this permission notice shall be included in
94 * all copies or substantial portions of the Software.
95 *
96 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
97 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
98 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
99 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
100 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
101 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
102 * THE SOFTWARE.
103 * Usage:
104 * server side(WP):
105 * js_wp_editor( $settings );
106 * client side(jQuery):
107 * $('textarea').wp_editor( options );
108 */
109 public static function js_wp_editor( $settings = array() ) {
110 if ( ! class_exists( '\_WP_Editors' ) ) {
111 require( ABSPATH . WPINC . '/class-wp-editor.php' );
112 }
113
114 /*
115 ob_start();
116 wp_editor( '', 'jp_cc_id' );
117 ob_get_clean();
118 */
119 $set = \_WP_Editors::parse_settings( 'jp_cc_id', $settings );
120
121 if ( ! current_user_can( 'upload_files' ) ) {
122 $set['media_buttons'] = false;
123 }
124
125 if ( $set['media_buttons'] ) {
126 wp_enqueue_style( 'buttons' );
127 wp_enqueue_script( 'thickbox' );
128 wp_enqueue_style( 'thickbox' );
129 wp_enqueue_script( 'media-upload' );
130 wp_enqueue_script( 'wp-embed' );
131
132 $post = get_post( 1 );
133 if ( ! $post && ! empty( $GLOBALS['post_ID'] ) ) {
134 $post = $GLOBALS['post_ID'];
135 }
136 wp_enqueue_media( array(
137 'post' => $post,
138 ) );
139 }
140
141 \_WP_Editors::editor_settings( 'jp_cc_id', $set );
142
143 $jp_cc_vars = array(
144 'url' => get_home_url(),
145 'includes_url' => includes_url(),
146 );
147
148 wp_localize_script( 'jpcc-settings-page', 'jp_cc_wpeditor_vars', $jp_cc_vars );
149 }
150 }