Example #1
0
 /**
  * Removes the global block options if the user does not have the required permissions
  *
  * @since 1.0.0
  */
 public function global_permissions()
 {
     // Get the global block permissions
     $global_permissions = blox_get_option('global_permissions', 'manage_options');
     $global_permissions = !empty($global_permissions) ? $global_permissions : 'manage_options';
     if (!current_user_can($global_permissions)) {
         remove_menu_page('edit.php?post_type=blox');
     }
 }
Example #2
0
    /**
     * Print upgrade notice on settings tabs
     *
     * @since 1.0.0
     */
    public function settings_upgrade_notice()
    {
        $disable_notices = blox_get_option('disable_marketing_notices', '');
        if (!$disable_notices) {
            ?>
			<div class="blox-alert blox-alert-warning">
				<?php 
            echo sprintf(__('Enjoying %1$sBlox Lite%2$s but looking for more content options, visibility settings, hooks control, priority support, frequent updates and more? Then you should consider %3$supgrading%4$s to %1$sBlox%2$s. Happy with the free version and have no need to upgrade? Then you might as well turn off these notifications in the plugin %5$ssettings%4$s.', 'blox'), '<strong>', '</strong>', '<a href="https://www.bloxwp.com/?utm_source=blox-lite&utm_medium=plugin&utm_content=marketing-links&utm_campaign=Blox_Plugin_Links" target="_blank">', '</a>', '<a href="' . admin_url('edit.php?post_type=blox&page=blox-settings&tab=misc') . '">');
            ?>
			</div>
			<?php 
        }
    }
Example #3
0
    /**
     * Print global custom CSS if there is any...
     *
     * @since 1.0.0
     */
    public function print_global_custom_css() {
	
		$custom_css = blox_get_option( 'custom_css', '' );
		
		if ( $custom_css ){
			echo '<style type="text/css">'. $custom_css . '</style>';
		}
	}
Example #4
0
    /**
     * Creates all of the fields for our style settings
     *
     * @since 1.0.0
     *
     * @param int $id             The block id 
     * @param string $name_prefix The prefix for saving each setting
     * @param string $get_prefix  The prefix for retrieving each setting
     * @param bool $global	      Determines if the content being loaded for local or global blocks
     */
    public function style_settings($id, $name_prefix, $get_prefix, $global)
    {
        // Check is default Blox CSS is globally disabled
        $global_disable_default_css = blox_get_option('disable_default_css');
        // Get the type of block we are working with
        $block_scope = $global ? 'global' : 'local';
        ?>
		<table class="form-table">
			<tbody>
				<tr>
					<th scope="row"><?php 
        _e('Custom Block Classes', 'blox');
        ?>
</th>
					<td>
						<input type="text" class="blox-half-text" name="<?php 
        echo $name_prefix;
        ?>
[custom_classes]" value="<?php 
        echo !empty($get_prefix['custom_classes']) ? esc_attr($get_prefix['custom_classes']) : '';
        ?>
" placeholder="e.g. class-one class-two"/>
						<div class="blox-description">
							<?php 
        _e('Enter a space separated list of custom CSS classes to add to this content block.', 'blox');
        ?>
						</div>
					</td>
				</tr>
				<tr>
					<th scope="row"><?php 
        _e('Custom Block CSS', 'blox');
        ?>
</th>
					<td>
						<textarea class="blox-textarea-code" name="<?php 
        echo $name_prefix;
        ?>
[custom_css]" rows="6" placeholder="<?php 
        echo 'e.g. #blox_' . $block_scope . '_' . $id . ' { border: 1px solid green; }';
        ?>
"><?php 
        echo !empty($get_prefix['custom_css']) ? esc_html($get_prefix['custom_css']) : '';
        ?>
</textarea>	
						<div class="blox-description">
							<?php 
        echo __('All custom CSS for this block should begin with ', 'blox') . '<code>#blox_' . $block_scope . '_' . $id . '</code>. ' . sprintf(__('Otherwise the custom CSS could interfere with other content blocks. For reference on content block frontend markup, please refer to the %1$sBlox Documentation%2$s.', 'blox'), '<a href="https://www.bloxwp.com/documentation/frontend-markup/?utm_source=blox-lite&utm_medium=plugin&utm_content=style-tab-links&utm_campaign=Blox_Plugin_Links" title="' . __('Blox Documentation', 'blox') . '" target="_blank"target="_blank">', '</a>');
        ?>
						</div>
					</td>
				</tr>
				<tr class="<?php 
        echo !empty($global_disable_default_css) ? 'blox-hidden' : '';
        ?>
">
					<th scope="row"><?php 
        _e('Disable Default CSS', 'blox');
        ?>
</th>
					<td>
						<label>
							<input type="checkbox" name="<?php 
        echo $name_prefix;
        ?>
[disable_default_css]" value="1" <?php 
        !empty($get_prefix['disable_default_css']) ? checked(esc_attr($get_prefix['disable_default_css'])) : '';
        ?>
 />
							<?php 
        _e('Check to disable all default styles on this block', 'blox');
        ?>
						</label>
						<span class="blox-help-text-icon">
							<a href="#" class="dashicons dashicons-editor-help" onclick="helpIcon.toggleHelp(this);return false;"></a>
						</span>
						<div class="blox-help-text top">
							<?php 
        echo __('Blox includes default CSS to provide minimal styling. This option will remove all default styling from this block, which can be useful when custom CSS is used extensively.', 'blox');
        ?>
						</div>
					</td>
				</tr>
				<tr>
					<th scope="row"><?php 
        _e('Enable Wrap', 'blox');
        ?>
</th>
					<td>
						<label>
							<input type="checkbox" name="<?php 
        echo $name_prefix;
        ?>
[enable_wrap]" value="1" <?php 
        !empty($get_prefix['enable_wrap']) ? checked(esc_attr($get_prefix['enable_wrap'])) : '';
        ?>
 />
							<?php 
        echo sprintf(__('Check to include the %1$swrap%2$s CSS selector in the block markup.', 'blox'), '<code>', '</code>');
        ?>
						</label>
						<span class="blox-help-text-icon">
							<a href="#" class="dashicons dashicons-editor-help" onclick="helpIcon.toggleHelp(this);return false;"></a>
						</span>
						<div class="blox-help-text top">
							<?php 
        _e('Many Genesis child themes use this selector and enabling it can assist with block styling.', 'blox');
        ?>
						</div>
					</td>
				</tr>
				
				<?php 
        do_action('blox_style_settings', $id, $name_prefix, $get_prefix, $global);
        ?>
	
				
			</tbody>
		</table>
		<?php 
    }
Example #5
0
 /**
  * Conditionally add the Local Blocks column to admin pages
  *
  * @since 1.0.0
  *
  * @global string $typenow The current post type.
  */
 public function local_blocks_columns()
 {
     global $typenow;
     $local_enable = blox_get_option('local_enable', false);
     if ($local_enable) {
         $enabled_pages = blox_get_option('local_enabled_pages', '');
         // Note this does not work on some custom post types in other plugins, need to explore reason...
         if (!empty($enabled_pages) && in_array($typenow, $enabled_pages)) {
             add_filter('manage_' . $typenow . '_posts_columns', array($this, 'local_blocks_column_title'), 5);
             add_action('manage_' . $typenow . '_posts_custom_column', array($this, 'local_blocks_column_data'), 10, 2);
             // Tell Wordpress that the Local Blocks column is sortable
             add_filter('manage_edit-' . $typenow . '_sortable_columns', array($this, 'local_blocks_columns_sortable'), 5);
         }
     }
     // Tell Wordpress how to sort Local Blocks
     add_filter('request', array($this, 'local_blocks_columns_orderby'));
 }
Example #6
0
 /**
  * Returns the post types to skip for loading Blox metaboxes
  *
  * @since 1.0.0
  *
  * @param bool $blox Whether or not to include the blox post type
  * @return array     Array of skipped posttypes
  */
 public function get_skipped_posttypes($blox = false)
 {
     $post_types = get_post_types();
     $local_enabled_pages = blox_get_option('local_enabled_pages', '');
     // Remove the blox post type from the "skipped" array
     if (!$blox) {
         unset($post_types['blox']);
     }
     // Loop through all enabled post types and remove them from the "skipped" array
     if (!empty($local_enabled_pages)) {
         foreach ($local_enabled_pages as $local_enabled_page) {
             unset($post_types[$local_enabled_page]);
         }
     }
     return apply_filters('blox_skipped_posttypes', $post_types);
 }
Example #7
0
 /**
  * Print the admin column data for global blocks.
  *
  * @param string $post_id
  * @param array $block_data
  */
 public function admin_column_data($post_id, $block_data)
 {
     $error = '<span style="color:#a00;font-style:italic;">' . __('Error', 'blox') . '</span>';
     if (!empty($block_data['position']['position_type'])) {
         if ($block_data['position']['position_type'] == 'default') {
             $default_position = esc_attr(blox_get_option('global_default_position', 'genesis_after_header'));
             if (!empty($default_position)) {
                 $position = $meta_data = esc_attr(blox_get_option('global_default_position', 'genesis_after_header'));
             } else {
                 $position = $error;
                 $meta_data = '';
             }
         } else {
             if (!empty($block_data['position']['custom'])) {
                 if (!empty($block_data['position']['custom']['position'])) {
                     $position = $meta_data = esc_attr($block_data['position']['custom']['position']);
                 } else {
                     $position = $error;
                     $meta_data = '';
                 }
             }
         }
     } else {
         $position = $error;
         $meta_data = '';
     }
     echo $position;
     // Save our position meta values separately for sorting
     update_post_meta($post_id, '_blox_content_blocks_position', $meta_data);
 }