/home/vianto5/cititower.mx/wp-content/plugins/siteorigin-panels
Edit: /home/vianto5/cititower.mx/wp-content/plugins/siteorigin-panels/siteorigin-panels.php (24377B)
\d+)/i', $agent, $B ) && $B['v'] <= 7 ) ||
// Chrome lte 25
( preg_match( '/Chrome\/(?P
\d+)/i', $agent, $B ) && $B['v'] <= 25 ) ||
// Firefox lte 21
( preg_match( '/Firefox\/(?P\d+)/i', $agent, $B ) && $B['v'] <= 21 ) ||
// Safari lte 7
( preg_match( '/Version\/(?P\d+).*?Safari\/\d+/i', $agent, $B ) && $B['v'] <= 6 );
}
/**
* Autoload Page Builder specific classses.
*/
public static function autoloader( $class ) {
$filename = false;
if ( strpos( $class, 'SiteOrigin_Panels_Widgets_' ) === 0 ) {
$filename = str_replace( 'SiteOrigin_Panels_Widgets_', '', $class );
$filename = str_replace( '_', '-', $filename );
$filename = strtolower( preg_replace( '/([a-z])([A-Z])/', '$1-$2', $filename ) );
$filename = plugin_dir_path( __FILE__ ) . 'inc/widgets/' . $filename . '.php';
} elseif ( strpos( $class, 'SiteOrigin_Panels_Compat_' ) === 0 ) {
$filename = str_replace( array( 'SiteOrigin_Panels_Compat_', '_' ), array( '', '-' ), $class );
$filename = plugin_dir_path( __FILE__ ) . 'compat/' . strtolower( $filename ) . '.php';
} elseif ( strpos( $class, 'SiteOrigin_Panels_' ) === 0 ) {
$filename = str_replace( array( 'SiteOrigin_Panels_', '_' ), array( '', '-' ), $class );
$filename = plugin_dir_path( __FILE__ ) . 'inc/' . strtolower( $filename ) . '.php';
}
if ( ! empty( $filename ) && file_exists( $filename ) ) {
include $filename;
}
}
public static function activate() {
add_option( 'siteorigin_panels_initial_version', SITEORIGIN_PANELS_VERSION, '', 'no' );
}
/**
* Initialize SiteOrigin Page Builder
*
* @action plugins_loaded
*/
public function init() {
if (
! is_admin() &&
siteorigin_panels_setting( 'sidebars-emulator' ) &&
( ! get_option( 'permalink_structure' ) || get_option( 'rewrite_rules' ) )
) {
// Initialize the sidebars emulator.
SiteOrigin_Panels_Sidebars_Emulator::single();
}
// Initialize the language.
load_plugin_textdomain( 'siteorigin-panels', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
// Initialize all the extra classes.
SiteOrigin_Panels_Home::single();
// Check if we need to initialize the admin class.
if ( is_admin() ) {
SiteOrigin_Panels_Admin::single();
}
}
/**
* Loads Page Builder compatibility to allow other plugins/themes
*/
public function init_compat() {
if ( defined( 'PAGELAYER_VERSION' ) ) {
SiteOrigin_Panels_Compat_Pagelayer::single();
}
}
/**
* @return mixed|void Are we currently viewing the home page.
*/
public static function is_home() {
$home = ( is_front_page() && is_page() && get_option( 'show_on_front' ) == 'page' && get_option( 'page_on_front' ) == get_the_ID() && get_post_meta( get_the_ID(), 'panels_data' ) );
return apply_filters( 'siteorigin_panels_is_home', $home );
}
/**
* Check if we're currently viewing a page builder page.
*
* @param bool $can_edit Also check if the user can edit this page
*
* @return bool
*/
public static function is_panel( $can_edit = false ) {
// Check if this is a panel
$is_panel = ( siteorigin_panels_is_home() || ( is_singular() && get_post_meta( get_the_ID(), 'panels_data', false ) ) );
return $is_panel && ( ! $can_edit || ( ( is_singular() && current_user_can( 'edit_post', get_the_ID() ) ) || ( siteorigin_panels_is_home() && current_user_can( 'edit_theme_options' ) ) ) );
}
/**
* Check if we're in the Live Editor in the frontend.
*
* @return bool
*/
public static function is_live_editor() {
return ! empty( $_GET['siteorigin_panels_live_editor'] );
}
public static function preview_url() {
global $post, $wp_post_types;
if (
empty( $post ) ||
empty( $wp_post_types ) ||
empty( $wp_post_types[ $post->post_type ] ) ||
! $wp_post_types[ $post->post_type ]->public
) {
$preview_url = add_query_arg(
'siteorigin_panels_live_editor',
'true',
admin_url( 'admin-ajax.php?action=so_panels_live_editor_preview' )
);
} else {
$preview_url = add_query_arg( 'siteorigin_panels_live_editor', 'true', set_url_scheme( get_permalink() ) );
}
$preview_url = wp_nonce_url( $preview_url, 'live-editor-preview', '_panelsnonce' );
return $preview_url;
}
public static function container_settings() {
$container = array(
'selector' => apply_filters( 'siteorigin_panels_theme_container_selector', '' ),
'width' => apply_filters( 'siteorigin_panels_theme_container_width', '' ),
'full_width' => false,
);
$container['css_override'] = ! empty( $container['selector'] ) && ! empty( $container['width'] );
return $container;
}
/**
* Get the Page Builder data for the home page.
*
* @return bool|mixed
*/
public function get_home_page_data() {
$page_id = get_option( 'page_on_front' );
if ( empty( $page_id ) ) {
$page_id = get_option( 'siteorigin_panels_home_page_id' );
}
if ( empty( $page_id ) ) {
return false;
}
$panels_data = get_post_meta( $page_id, 'panels_data', true );
if ( is_null( $panels_data ) ) {
// Load the default layout
$layouts = apply_filters( 'siteorigin_panels_prebuilt_layouts', array() );
$panels_data = ! empty( $layouts['default_home'] ) ? $layouts['default_home'] : current( $layouts );
}
return $panels_data;
}
/**
* Generate post content for WooCommerce shop page if it's using a PB layout.
*
* @return string
*
* @filter woocommerce_format_content
*/
public function generate_woocommerce_content( $content ) {
if ( self::should_use_woocommerce_shop_page_id() ) {
return $this->generate_post_content( $content );
}
return $content;
}
/**
* Generate post content for the current post.
*
* @return string
*
* @filter the_content
*/
public function generate_post_content( $content ) {
global $post, $preview;
if ( empty( $post ) && ! in_the_loop() ) {
return $content;
}
if ( ! apply_filters( 'siteorigin_panels_filter_content_enabled', true ) ) {
return $content;
}
$post_id = $this->get_post_id();
// Check if this post has panels_data.
if ( get_post_meta( $post_id, 'panels_data', true ) ) {
$original_post = $post;
$panel_content = SiteOrigin_Panels::renderer()->render(
$post_id,
// Add CSS if this is not the main single post, this is handled by add_single_css.
$preview || $post_id !== get_queried_object_id()
);
// Some widgets call wp_reset_postdata() while rendering and can alter global $post.
// Restore it so downstream the_content filters still receive the current post context.
$post = $original_post;
if ( ! empty( $panel_content ) ) {
$content = $panel_content;
if ( ! is_singular() ) {
// This is an archive page, so try strip out anything after the more text.
if ( preg_match( '//', $content, $matches ) ) {
$content = explode( $matches[0], $content, 2 );
$content = $content[0];
$content = force_balance_tags( $content );
if ( ! empty( $matches[1] ) ) {
$more_link_text = strip_tags( wp_kses_no_null( trim( $matches[1] ) ) );
} else {
$more_link_text = __( 'Read More', 'siteorigin-panels' );
}
$more_link = apply_filters( 'the_content_more_link', ' ID}\" class=\"more-link\">$more_link_text", $more_link_text );
$content .= '' . $more_link . '
';
}
}
}
}
return $content;
}
/**
* Generate an excerpt for the current post, if possible.
*
* @return mixed|string
*/
public function generate_post_excerpt( $text ) {
global $post;
if ( ( empty( $post ) && ! in_the_loop() ) || $text !== '' ) {
return $text;
}
$post_id = $this->get_post_id();
$panels_data = get_post_meta( $post_id, 'panels_data', true );
// If no panels_data is detected, check if the post has blocks.
if ( empty( $panels_data ) ) {
if ( function_exists( 'has_blocks' ) && has_blocks( get_the_content() ) ) {
$parsed_content = parse_blocks( get_the_content() );
// Check if the first block is an SO Layout Block, and extract panels_data if it is.
if (
$parsed_content[0]['blockName'] == 'siteorigin-panels/layout-block' &&
isset( $parsed_content[0]['attrs'] ) &&
! empty( $parsed_content[0]['attrs']['panelsData'] )
) {
$panels_data = $parsed_content[0]['attrs']['panelsData'];
}
}
}
if ( $panels_data && ! empty( $panels_data['widgets'] ) ) {
$raw_excerpt = '';
$excerpt_length = apply_filters( 'excerpt_length', 55 );
foreach ( $panels_data['widgets'] as $widget ) {
// Is the widget valid?
if ( empty( $widget['panels_info'] ) ) {
continue;
}
$panels_info = $widget['panels_info'];
if ( $panels_info['grid'] > 1 ) {
// Limiting search for a text type widget to the first two PB rows to avoid having excerpt content
// that's very far down in a post.
break;
}
$widgets = apply_filters( 'siteorigin_panels_excerpt_widgets', array(
'SiteOrigin_Widget_Editor_Widget',
'WP_Widget_Text',
'WP_Widget_Black_Studio_TinyMCE',
) );
if ( empty( $widgets ) ) {
break;
}
if ( in_array( $panels_info['class'], $widgets ) ) {
if ( empty( $widget['text'] ) ) {
continue;
}
$raw_excerpt .= ' ' . $widget['text'];
// This is all effectively default behavior for excerpts, copied from the `wp_trim_excerpt` function.
// We're just applying it to text type widgets content in the first two rows.
$text = strip_shortcodes( $raw_excerpt );
$text = str_replace( ']]>', ']]>', $text );
if ( $this->get_localized_word_count( $text ) >= $excerpt_length ) {
break;
}
// Check for more quicktag.
if ( strpos( $text, '