| @@ -103,9 +103,9 @@ | ||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // Register block. |
| 106 | 106 | register_block_type( |
| 107 | - 'convertkit/' . $block, | |
| 107 | + CONVERTKIT_PLUGIN_PATH . '/includes/blocks/' . $block, | |
| 108 | 108 | array( |
| 109 | 109 | 'attributes' => $properties['attributes'], |
| 110 | 110 | 'editor_script' => 'convertkit-gutenberg', |
| 111 | 111 | 'render_callback' => array( |
| @@ -113,13 +113,14 @@ | ||
| 113 | 113 | $properties['render_callback'][1], |
| 114 | 114 | ), |
| 115 | 115 | ) |
| 116 | 116 | ); |
| 117 | + | |
| 117 | 118 | } |
| 118 | 119 | |
| 119 | 120 | // Enqueue block scripts and styles in the editor view. |
| 120 | 121 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
| 121 | - add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_styles' ) ); | |
| 122 | + add_action( 'enqueue_block_assets', array( $this, 'enqueue_styles' ) ); | |
| 122 | 123 | |
| 123 | 124 | // Enqueue block scripts and styles in the editor and frontend views. |
| 124 | 125 | add_action( 'enqueue_block_assets', array( $this, 'enqueue_scripts_editor_and_frontend' ) ); |
| 125 | 126 | add_action( 'enqueue_block_assets', array( $this, 'enqueue_styles_editor_and_frontend' ) ); |
| @@ -141,14 +142,25 @@ | ||
| 141 | 142 | // Get settings. |
| 142 | 143 | $settings = new ConvertKit_Settings(); |
| 143 | 144 | |
| 144 | 145 | // Get blocks and block toolbar buttons. |
| 145 | - $blocks = convertkit_get_blocks(); | |
| 146 | - $block_formatters = convertkit_get_block_formatters(); | |
| 146 | + $blocks = convertkit_get_blocks(); | |
| 147 | + $block_formatters = convertkit_get_block_formatters(); | |
| 148 | + $pre_publish_actions = convertkit_get_pre_publish_actions(); | |
| 147 | 149 | |
| 148 | 150 | // Enqueue Gutenberg Javascript, and set the blocks data. |
| 149 | 151 | wp_enqueue_script( 'convertkit-gutenberg', CONVERTKIT_PLUGIN_URL . 'resources/backend/js/gutenberg.js', array( 'jquery' ), CONVERTKIT_PLUGIN_VERSION, true ); |
| 150 | 152 | wp_localize_script( 'convertkit-gutenberg', 'convertkit_blocks', $blocks ); |
| 153 | + if ( count( $pre_publish_actions ) ) { | |
| 154 | + wp_localize_script( 'convertkit-gutenberg', 'convertkit_pre_publish_actions', $pre_publish_actions ); | |
| 155 | + } | |
| 156 | + wp_localize_script( | |
| 157 | + 'convertkit-gutenberg', | |
| 158 | + 'convertkit_gutenberg', | |
| 159 | + array( | |
| 160 | + 'get_blocks_nonce' => wp_create_nonce( 'convertkit_get_blocks' ), | |
| 161 | + ) | |
| 162 | + ); | |
| 151 | 163 | |
| 152 | 164 | // Enqueue Gutenberg Block Toolbar Javascript, and set the block toolbar buttons data. |
| 153 | 165 | wp_enqueue_script( 'convertkit-gutenberg-block-formatters', CONVERTKIT_PLUGIN_URL . 'resources/backend/js/gutenberg-block-formatters.js', array( 'jquery' ), CONVERTKIT_PLUGIN_VERSION, true ); |
| 154 | 166 | wp_localize_script( 'convertkit-gutenberg-block-formatters', 'convertkit_block_formatters', $block_formatters ); |
| @@ -174,10 +186,10 @@ | ||
| 174 | 186 | * @since 1.9.6.9 |
| 175 | 187 | */ |
| 176 | 188 | public function enqueue_styles() { |
| 177 | 189 | |
| 178 | - // Bail if request isn't for the Admin or a Frontend Editor. | |
| 179 | - if ( ! WP_ConvertKit()->is_admin_or_frontend_editor() ) { | |
| 190 | + // Bail if request isn't for the Admin. | |
| 191 | + if ( ! is_admin() ) { | |
| 180 | 192 | return; |
| 181 | 193 | } |
| 182 | 194 | |
| 183 | 195 | /** |