/** * This function just gives active widgets a chance to enqueue their scripts */ function siteorigin_widgets_enqueue_widget_scripts() { global $wp_registered_widgets, $post; $active_widgets = array(); $panel_widget_classes = array(); if (is_singular()) { $panels_data = get_post_meta($post->ID, 'panels_data', true); } elseif (function_exists('siteorigin_panels_is_home') && siteorigin_panels_is_home()) { $panels_data = get_option('siteorigin_panels_home_page', null); } if (!empty($panels_data['widgets'])) { foreach ($panels_data['widgets'] as $widget) { $panel_widget_classes[] = $widget['info']['class']; } } foreach ($wp_registered_widgets as $widget) { if (!empty($widget['callback'][0]) && is_object($widget['callback'][0])) { if (is_active_widget(false, false, $widget['callback'][0]->id_base)) { $active_widgets[] = $widget['callback'][0]->id_base; } if (!empty($panel_widget_classes) && in_array(get_class($widget['callback'][0]), $panel_widget_classes)) { $active_widgets[] = $widget['callback'][0]->id_base; } } } $active_widgets = array_unique($active_widgets); foreach ($active_widgets as $widget) { do_action('siteorigin_enqueue_widget_scripts_' . $widget); } }
/** * Display a special Origami image gallery * * @param $contents * @param $atts * @return string */ function origami_gallery($contents, $attr) { if (!siteorigin_setting('display_gallery')) { return $contents; } if (!empty($attr['type']) && $attr['type'] == 'default') { return ''; } if (siteorigin_panels_is_home() && empty($attr['ids'])) { // Display the default Origami gallery return origami_gallery_default(); } global $post; static $instance = 0; $instance++; // We're trusting author input, so let's at least make sure it looks like a valid orderby statement if (isset($attr['orderby'])) { $attr['orderby'] = sanitize_sql_orderby($attr['orderby']); if (!$attr['orderby']) { unset($attr['orderby']); } } /** * @var $order * @var $orderby * @var $id * @var $itemtag * @var $icontag * @var $captiontag * @var $size * @var $include * @var $exclude * @var $wp_default * @var $target_blank */ extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'origami-slider', 'include' => '', 'exclude' => '', 'wp_default' => false, 'target_blank' => false), $attr)); // This gallery has requested to use the WordPress default gallery if ($wp_default) { return $contents; } $id = intval($id); if ('RAND' == $order) { $orderby = 'none'; } if (!empty($include)) { $include = preg_replace('/[^0-9,]+/', '', $include); $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); $attachments = array(); foreach ($_attachments as $key => $val) { $attachments[$val->ID] = $_attachments[$key]; } } elseif (!empty($exclude)) { $exclude = preg_replace('/[^0-9,]+/', '', $exclude); $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } else { $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } if (empty($attachments)) { return ''; } // This is the custom stuff // Create the gallery content $return = ''; $return .= '<div class="flexslider-wrapper">'; $return .= '<div class="flexslider">'; $return .= '<ul class="slides">'; foreach ($attachments as $attachment) { $return .= '<li>'; $return .= apply_filters('origami_slide_before', '', $attachment, $target_blank); $return .= wp_get_attachment_image($attachment->ID, $size, false, array('class' => 'slide-image')); if ($attachment->post_excerpt) { $return .= '<div class="flex-caption">' . $attachment->post_excerpt . '</div>'; } $return .= apply_filters('origami_slide_after', '', $attachment, $target_blank); $return .= '</li>'; } $return .= '</ul>'; $return .= '</div>'; $return .= '</div>'; return $return; }
/** * Add all the necessary body classes. * * @param $classes * @return array */ function siteorigin_panels_body_class($classes) { if (siteorigin_panels_is_panel()) { $classes[] = 'siteorigin-panels'; } if (siteorigin_panels_is_home()) { $classes[] = 'siteorigin-panels-home'; } return $classes; }
/** * Add all the necessary body classes. * * @param $classes * @return array */ function siteorigin_panels_body_class($classes) { if (siteorigin_panels_is_panel()) { $classes[] = 'siteorigin-panels'; } if (siteorigin_panels_is_home()) { $classes[] = 'siteorigin-panels-home'; } if (isset($_GET['siteorigin_panels_preview']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'siteorigin-panels-preview')) { // This is a home page preview $classes[] = 'siteorigin-panels'; $classes[] = 'siteorigin-panels-home'; } return $classes; }
function origami_post_class_columns($classes, $class, $post_id) { if (!siteorigin_setting('display_use_columns')) { return $classes; } if (is_page() && get_post_meta(get_the_ID(), 'panels_data')) { return $classes; } if (function_exists('siteorigin_panels_is_home') && siteorigin_panels_is_home()) { return $classes; } $columns = get_post_meta($post_id, 'content_columns', true); if (!empty($columns)) { $classes[] = 'content-columns-' . $columns; } return $classes; }
/** * Add the Edit Home Page item to the admin bar. * * @param WP_Admin_Bar $admin_bar * @return WP_Admin_Bar */ function siteorigin_panels_admin_bar_menu($admin_bar) { /** * @var WP_Query $wp_query */ global $wp_query; if ($wp_query->is_home() && $wp_query->is_main_query() || siteorigin_panels_is_home()) { // Check that we support the home page if (!siteorigin_panels_setting('home-page') || !current_user_can('edit_theme_options')) { return $admin_bar; } $admin_bar->add_node(array('id' => 'edit-home-page', 'title' => __('Edit Home Page', 'so-panels'), 'href' => admin_url('themes.php?page=so_panels_home_page'))); } return $admin_bar; }