/** * Select Genesis Hooks Callback. Renders select fields. * * @since 1.0.0 * * @param array $args Arguments passed by the setting * @global $blox_options Array of all the Blox settings * @return void */ public function select_hooks_callback($args) { global $blox_options; $instance = Blox_Common::get_instance(); $hooks = $instance->get_genesis_hooks(); if (isset($blox_options[$args['id']])) { $value = $blox_options[$args['id']]; } else { $value = isset($args['default']) ? $args['default'] : ''; } $html = '<select id="blox_settings[' . $args['id'] . ']" name="blox_settings[' . $args['id'] . ']" />'; foreach ($hooks as $sections => $section) { $html .= '<optgroup label="' . $section['name'] . '">'; foreach ($section['hooks'] as $hooks => $hook) { $selected = selected($hooks, esc_attr($value), false); $html .= '<option value="' . $hooks . '" ' . $selected . '>' . $hook['name'] . '</option>'; } $html .= '</optgroup>'; } $html .= '</select>'; $html .= !empty($args['desc']) ? '<p class="description">' . $args['desc'] . '</p>' : ''; echo $html; }
/** * Helper function that get the content from the content block * Needs to remain outside the Blox_Frontend class due to Blox_Action_Storage ---> Possibly find work around... * * @since 1.0.0 * * @param array $args These are any args associated to the action hook by default * @param array $parameters Additional args that we are passing to the action hook (whole point of using Block_Action_Storage) */ function blox_frontend_content( $args, $parameters ) { // Reassign the parameters $id = $parameters[0]; $block = $parameters[1]; $global = $parameters[2]; // Get the type of block we are working with $block_scope = $global ? 'global' : 'local'; // Get block settings $content_data = $block['content']; $style_data = $block['style']; // Get access to some of our helper functions $instance = Blox_Common::get_instance(); // Check is default Blox CSS is globally disabled $global_disable_default_css = blox_get_option( 'disable_default_css', '' ); // Start with no theme $blox_theme = ''; // Should we include our default styles? If so, add the default theme if ( empty( $global_disable_default_css ) ) { if ( empty( $style_data['disable_default_css'] ) || ! $style_data['disable_default_css'] ) { $blox_theme = 'blox-theme-default'; } } // If this block has its own custom css, add that before the block is displayed on the page if ( ! empty( $style_data['custom_css'] ) ) { echo '<style type="text/css">' . $instance->minify_string( html_entity_decode( $style_data['custom_css'] ) ) . '</style>'; } // Make sure a content type is selected and then print our content block if ( ! empty( $content_data['content_type'] ) ) { if ( $content_data['content_type'] == 'raw' && $content_data['raw']['disable_markup'] == 1 ) { // Get the block content do_action( 'blox_print_content_' . $content_data['content_type'], $content_data, $id, $block, $global ); } else { ?> <div id="<?php echo 'blox_' . $block_scope . '_' . esc_attr( $id ); ?>" class="blox-container <?php echo 'blox-content-' . esc_attr( $content_data['content_type'] ); ?> <?php echo $blox_theme; ?> <?php echo 'blox-scope-' . $block_scope; ?> <?php echo ! empty( $style_data['custom_classes'] ) ? esc_attr( $style_data['custom_classes'] ) : '';?>"> <div class="blox-wrap <?php echo $style_data['enable_wrap'] == 1 ? 'wrap' : '';?>"> <?php do_action( 'blox_print_content_' . $content_data['content_type'], $content_data, $id, $block, $global ); ?> </div> </div> <?php } } }
/** * Helper function for retrieving the available content types. * * @since 1.0.0 * * @return array Array of all content types. */ public function get_content_types() { $instance = Blox_Common::get_instance(); return $instance->get_content_types(); }
/** * Helper method for retrieving image sizes. * * @since 1.0.0 * * @return array Array of image size data. */ public function get_image_sizes() { $instance = Blox_Common::get_instance(); return $instance->get_image_sizes(); }
/** * Helper method for retrieving all Genesis hooks. * * @since 1.0.0 * * @return array Array of all Genesis hooks. */ public function get_genesis_hooks() { $instance = Blox_Common::get_instance(); return $instance->get_genesis_hooks(); }
*/ public function minify_string( $string ) { $clean = preg_replace( '/((?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:\/\/.*))/', '', $string ); $clean = str_replace( array( "\r\n", "\r", "\t", "\n", ' ', ' ', ' ' ), '', $clean ); return apply_filters( 'blox_minified_string', $clean, $string ); } /** * Returns the singleton instance of the class. * * @since 1.0.0 * * @return object The class object. */ public static function get_instance() { if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Blox_Common ) ) { self::$instance = new Blox_Common(); } return self::$instance; } } // Load the common class. $blox_common = Blox_Common::get_instance();