| @@ -115,20 +115,16 @@ | ||
| 115 | 115 | ) |
| 116 | 116 | ); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - // Enqueue block scripts and styles in the editor view. | |
| 119 | + // Enqueue Gutenberg Block scripts and styles. | |
| 120 | 120 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
| 121 | 121 | add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_styles' ) ); |
| 122 | 122 | |
| 123 | - // Enqueue block scripts and styles in the editor and frontend views. | |
| 124 | - add_action( 'enqueue_block_assets', array( $this, 'enqueue_scripts_editor_and_frontend' ) ); | |
| 125 | - add_action( 'enqueue_block_assets', array( $this, 'enqueue_styles_editor_and_frontend' ) ); | |
| 126 | - | |
| 127 | 123 | } |
| 128 | 124 | |
| 129 | 125 | /** |
| 130 | - * Enqueues scripts for Gutenberg blocks in the editor view. | |
| 126 | + * Enqueues scripts for Gutenberg blocks. | |
| 131 | 127 | * |
| 132 | 128 | * @since 1.9.6 |
| 133 | 129 | */ |
| 134 | 130 | public function enqueue_scripts() { |
| @@ -140,45 +136,29 @@ | ||
| 140 | 136 | |
| 141 | 137 | // Get settings. |
| 142 | 138 | $settings = new ConvertKit_Settings(); |
| 143 | 139 | |
| 144 | - // Get blocks and block toolbar buttons. | |
| 145 | - $blocks = convertkit_get_blocks(); | |
| 146 | - $block_formatters = convertkit_get_block_formatters(); | |
| 140 | + // Get blocks. | |
| 141 | + $blocks = convertkit_get_blocks(); | |
| 147 | 142 | |
| 148 | 143 | // Enqueue Gutenberg Javascript, and set the blocks data. |
| 149 | - wp_enqueue_script( 'convertkit-gutenberg', CONVERTKIT_PLUGIN_URL . 'resources/backend/js/gutenberg.js', array( 'jquery' ), CONVERTKIT_PLUGIN_VERSION, true ); | |
| 144 | + wp_enqueue_script( 'convertkit-gutenberg', CONVERTKIT_PLUGIN_URL . '/resources/backend/js/gutenberg.js', array( 'jquery' ), CONVERTKIT_PLUGIN_VERSION, true ); | |
| 150 | 145 | wp_localize_script( 'convertkit-gutenberg', 'convertkit_blocks', $blocks ); |
| 151 | - wp_localize_script( | |
| 152 | - 'convertkit-gutenberg', | |
| 153 | - 'convertkit_gutenberg', | |
| 154 | - array( | |
| 155 | - 'get_blocks_nonce' => wp_create_nonce( 'convertkit_get_blocks' ), | |
| 156 | - ) | |
| 157 | - ); | |
| 158 | 146 | |
| 159 | - // Enqueue Gutenberg Block Toolbar Javascript, and set the block toolbar buttons data. | |
| 160 | - wp_enqueue_script( 'convertkit-gutenberg-block-formatters', CONVERTKIT_PLUGIN_URL . 'resources/backend/js/gutenberg-block-formatters.js', array( 'jquery' ), CONVERTKIT_PLUGIN_VERSION, true ); | |
| 161 | - wp_localize_script( 'convertkit-gutenberg-block-formatters', 'convertkit_block_formatters', $block_formatters ); | |
| 162 | - | |
| 163 | 147 | /** |
| 164 | 148 | * Enqueue any additional scripts for Gutenberg blocks that have been registered. |
| 165 | 149 | * |
| 166 | 150 | * @since 1.9.6.5 |
| 167 | 151 | * |
| 168 | - * @param array $blocks ConvertKit Blocks. | |
| 169 | - * @param array $block_formatters ConvertKit Block Formatters. | |
| 152 | + * @param array $blocks ConvertKit Blocks. | |
| 170 | 153 | */ |
| 171 | - do_action( 'convertkit_gutenberg_enqueue_scripts', $blocks, $block_formatters ); | |
| 154 | + do_action( 'convertkit_gutenberg_enqueue_scripts', $blocks ); | |
| 172 | 155 | |
| 173 | 156 | } |
| 174 | 157 | |
| 175 | 158 | /** |
| 176 | - * Enqueues styles for Gutenberg blocks in the editor view. | |
| 159 | + * Enqueues scripts for Gutenberg blocks. | |
| 177 | 160 | * |
| 178 | - * Use wp_enqueue_style() hooked to the enqueue_block_assets hook for frontend styles: | |
| 179 | - * https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/applying-styles-with-stylesheets/ | |
| 180 | - * | |
| 181 | 161 | * @since 1.9.6.9 |
| 182 | 162 | */ |
| 183 | 163 | public function enqueue_styles() { |
| 184 | 164 | |
| @@ -192,56 +172,8 @@ | ||
| 192 | 172 | * |
| 193 | 173 | * @since 1.9.6.9 |
| 194 | 174 | */ |
| 195 | 175 | do_action( 'convertkit_gutenberg_enqueue_styles' ); |
| 196 | - | |
| 197 | - } | |
| 198 | - | |
| 199 | - /** | |
| 200 | - * Enqueues scripts for Gutenberg blocks in both the editor and frontend view, | |
| 201 | - * if the Plugin's Disable JavaScript option is not enabled. | |
| 202 | - * | |
| 203 | - * @since 1.9.7.6 | |
| 204 | - */ | |
| 205 | - public function enqueue_scripts_editor_and_frontend() { | |
| 206 | - | |
| 207 | - // Don't load scripts if the Disable JS option is on. | |
| 208 | - $settings = new ConvertKit_Settings(); | |
| 209 | - if ( $settings->scripts_disabled() ) { | |
| 210 | - return; | |
| 211 | - } | |
| 212 | - | |
| 213 | - /** | |
| 214 | - * Enqueues scripts for Gutenberg blocks in both the editor and frontend view, | |
| 215 | - * if the Plugin's Disable JavaScript option is not enabled. | |
| 216 | - * | |
| 217 | - * @since 1.9.7.6 | |
| 218 | - */ | |
| 219 | - do_action( 'convertkit_gutenberg_enqueue_scripts_editor_and_frontend' ); | |
| 220 | - | |
| 221 | - } | |
| 222 | - | |
| 223 | - /** | |
| 224 | - * Enqueues styles for Gutenberg blocks in both the editor and frontend view, | |
| 225 | - * if the Plugin's Disable CSS option is not enabled. | |
| 226 | - * | |
| 227 | - * @since 1.9.7.6 | |
| 228 | - */ | |
| 229 | - public function enqueue_styles_editor_and_frontend() { | |
| 230 | - | |
| 231 | - // Don't load styles if the Disable CSS option is on. | |
| 232 | - $settings = new ConvertKit_Settings(); | |
| 233 | - if ( $settings->css_disabled() ) { | |
| 234 | - return; | |
| 235 | - } | |
| 236 | - | |
| 237 | - /** | |
| 238 | - * Enqueues styles for Gutenberg blocks in both the editor and frontend view, | |
| 239 | - * if the Plugin's Disable CSS option is not enabled. | |
| 240 | - * | |
| 241 | - * @since 1.9.7.6 | |
| 242 | - */ | |
| 243 | - do_action( 'convertkit_gutenberg_enqueue_styles_editor_and_frontend' ); | |
| 244 | 176 | |
| 245 | 177 | } |
| 246 | 178 | |
| 247 | 179 | } |