function get_mtphr_gallery($post_id = false, $args = false, $class = '') { // Get the post id $post_id = $post_id ? $post_id : get_the_id(); // Get all the custom data $custom_fields = get_post_custom($post_id); $meta_data = array(); foreach ($custom_fields as $key => $value) { $meta_data[$key] = maybe_unserialize($value[0]); } // Manually set the layout $meta_data['_mtphr_gallery_slider_layout'] = array('navigation', 'gallery'); // Override meta data with supplied attributes if (is_array($args)) { foreach ($args as $key => $value) { $meta_data["_mtphr_gallery_{$key}"] = $value; } } // Extract the metadata array into variables extract($meta_data); // Create the gallery $gallery_id = 'mtphr-gallery-' . $post_id; $html = '<div id="' . $gallery_id . '" class="mtphr-gallery ' . sanitize_html_class($class) . '">'; // Set the layout if (!is_array($_mtphr_gallery_slider_layout)) { $_mtphr_gallery_slider_layout = explode(',', $_mtphr_gallery_slider_layout); } foreach ($_mtphr_gallery_slider_layout as $asset) { switch ($asset) { case 'like': $html .= get_mtphr_gallery_likes(); break; case 'navigation': if (isset($_mtphr_gallery_slider_control_nav) && $_mtphr_gallery_slider_control_nav) { $html .= get_mtphr_galleries_navigation($post_id); } break; case 'gallery': $html .= '<div class="mtphr-gallery-wrapper">'; $html .= apply_filters('mtphr_gallery', get_mtphr_gallery_resources($post_id), $post_id); if (isset($_mtphr_gallery_slider_directional_nav) && $_mtphr_gallery_slider_directional_nav) { $html .= '<a href="#" class="mtphr-gallery-nav-prev" rel="nofollow">' . apply_filters('mtphr_gallery_navigation_previous', __('Previous', 'mtphr-galleries')) . '</a>'; $html .= '<a href="#" class="mtphr-gallery-nav-next" rel="nofollow">' . apply_filters('mtphr_gallery_navigation_next', __('Next', 'mtphr-galleries')) . '</a>'; } $html .= '</div>'; break; } } $html .= '</div>'; // Add an after action ob_start(); do_action('mtphr_gallery_slider_after', $gallery_id, $meta_data); $html .= ob_get_clean(); // Add to the gallery scripts to display in the footer global $mtphr_galleries_scripts; $rotate = 0; $pause = 0; $nav_autohide = 0; $nav_reverse = 0; if (isset($_mtphr_gallery_slider_auto_rotate)) { $rotate = $_mtphr_gallery_slider_auto_rotate ? 1 : 0; } if (isset($_mtphr_gallery_slider_pause)) { $pause = $_mtphr_gallery_slider_pause ? 1 : 0; } if (isset($_mtphr_gallery_slider_directional_nav_reverse)) { $nav_reverse = $_mtphr_gallery_slider_directional_nav_reverse ? 1 : 0; } $mtphr_galleries_scripts[] = array('id' => $gallery_id, 'rotate_type' => $_mtphr_gallery_slider_type, 'auto_rotate' => $rotate, 'rotate_delay' => intval($_mtphr_gallery_slider_delay), 'rotate_pause' => $pause, 'rotate_speed' => intval($_mtphr_gallery_slider_speed), 'rotate_ease' => $_mtphr_gallery_slider_ease, 'nav_reverse' => $nav_reverse); // Return the gallery return $html; }
/** * Return the gallery * * @since 2.0.13 */ function get_mtphr_gallery($post_id = false, $width = false, $height = false, $args = false, $class = '') { $settings = mtphr_galleries_settings(); // Get the post id $post_id = $post_id ? $post_id : get_the_id(); // Get all the custom data $custom_fields = get_post_custom($post_id); $meta_data = array(); foreach ($custom_fields as $key => $value) { $meta_data[$key] = maybe_unserialize($value[0]); } // Manually set the layout $meta_data['_mtphr_gallery_slider_layout'] = array('navigation', 'gallery'); // Override meta data with supplied attributes if (is_array($args)) { foreach ($args as $key => $value) { $meta_data["_mtphr_gallery_{$key}"] = $value; } } // Extract the metadata array into variables extract($meta_data); $control_nav = $settings['global_slider_settings'] == 'on' ? $settings['slider_control_nav'] == 'on' : isset($_mtphr_gallery_slider_control_nav) && $_mtphr_gallery_slider_control_nav; // Create the gallery $gallery_id = 'mtphr-gallery-' . $post_id; $html = '<div id="' . $gallery_id . '" class="mtphr-gallery ' . sanitize_html_class($class) . '">'; ob_start(); do_action('mtphr_gallery_slider_top', $post_id, $meta_data); $html .= ob_get_clean(); // Set the layout if (!is_array($_mtphr_gallery_slider_layout)) { $_mtphr_gallery_slider_layout = explode(',', $_mtphr_gallery_slider_layout); } foreach ($_mtphr_gallery_slider_layout as $asset) { switch ($asset) { case 'like': if ($control_nav) { $html .= get_mtphr_gallery_likes(); } break; case 'navigation': if ($control_nav) { $html .= get_mtphr_galleries_navigation($post_id); } break; case 'gallery': $html .= '<div class="mtphr-gallery-wrapper">'; // Add an after action ob_start(); do_action('mtphr_gallery_wrapper', $post_id, $meta_data); $html .= ob_get_clean(); $html .= '</div>'; break; } } ob_start(); do_action('mtphr_gallery_slider_bottom', $post_id, $meta_data); $html .= ob_get_clean(); $html .= '</div>'; // Add an after action ob_start(); do_action('mtphr_gallery_slider_after', $gallery_id, $meta_data); $html .= ob_get_clean(); // Add to the gallery scripts to display in the footer global $mtphr_galleries_scripts; if ($settings['global_slider_settings'] == 'on') { $mtphr_galleries_scripts = array('on'); } else { $rotate = 0; $pause = 0; $nav_autohide = 0; $nav_reverse = 0; if (isset($_mtphr_gallery_slider_auto_rotate)) { $rotate = $_mtphr_gallery_slider_auto_rotate ? 1 : 0; } if (isset($_mtphr_gallery_slider_pause)) { $pause = $_mtphr_gallery_slider_pause ? 1 : 0; } if (isset($_mtphr_gallery_slider_directional_nav_reverse)) { $nav_reverse = $_mtphr_gallery_slider_directional_nav_reverse ? 1 : 0; } if (!empty($_mtphr_gallery_slider_type)) { $mtphr_galleries_scripts[] = array('id' => $gallery_id, 'rotate_type' => $_mtphr_gallery_slider_type, 'auto_rotate' => $rotate, 'rotate_delay' => intval($_mtphr_gallery_slider_delay), 'rotate_pause' => $pause, 'rotate_speed' => intval($_mtphr_gallery_slider_speed), 'rotate_ease' => $_mtphr_gallery_slider_ease, 'nav_reverse' => $nav_reverse); } } // Return the gallery return $html; }