/** * Create a tags taxonomy * * @since 1.0.4 */ function mtphr_galleries_tags() { // Set the slug $settings = mtphr_galleries_settings(); $slug = $settings['slug'] . '-tag'; $singular = $settings['singular_label']; // Create labels $labels = array('name' => sprintf(__('%s Tags', 'mtphr-galleries'), $singular), 'singular_name' => __('Tag', 'mtphr-galleries'), 'search_items' => __('Search Tags', 'mtphr-galleries'), 'all_items' => __('All Tags', 'mtphr-galleries'), 'parent_item' => __('Parent', 'mtphr-galleries'), 'parent_item_colon' => __('Parent:', 'mtphr-galleries'), 'edit_item' => __('Edit Tag', 'mtphr-galleries'), 'update_item' => __('Update Tag', 'mtphr-galleries'), 'add_new_item' => __('Add New Tag', 'mtphr-galleries'), 'new_item_name' => __('New Tag', 'mtphr-galleries'), 'menu_name' => __('Tags', 'mtphr-galleries')); // Create the arguments $args = array('labels' => $labels, 'hierarchical' => false, 'show_admin_column' => true, 'rewrite' => array('slug' => $slug)); // Register the taxonomy register_taxonomy('mtphr_gallery_tag', array('mtphr_gallery'), $args); }
function mtphr_gallery_add_directional_nav($post_id, $meta_data) { $settings = mtphr_galleries_settings(); // Extract the metadata array into variables extract($meta_data); $directional_nav = $settings['global_slider_settings'] == 'on' ? $settings['slider_directional_nav'] == 'on' : isset($_mtphr_gallery_slider_directional_nav) && $_mtphr_gallery_slider_directional_nav; $resources = mtphr_gallery_resource_meta($post_id); if (is_array($resources) && count($resources) > 1) { $html = ''; if ($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>'; } echo $html; } }
/** * Add the gallery post type * * @since 1.0.9 */ function mtphr_galleries_posttype() { // Set the slug $settings = mtphr_galleries_settings(); $slug = $settings['slug']; $singular = $settings['singular_label']; $plural = $settings['plural_label']; $public = $settings['public'] == 'true' ? true : false; $has_archive = $settings['has_archive'] == 'true' ? true : false; // Create labels $labels = array('name' => sprintf(__('%s', 'mtphr-galleries'), $plural), 'singular_name' => sprintf(__('%s', 'mtphr-galleries'), $singular), 'add_new' => __('Add New', 'mtphr-galleries'), 'add_new_item' => sprintf(__('Add New %s', 'mtphr-galleries'), $singular), 'edit_item' => sprintf(__('Edit %s', 'mtphr-galleries'), $singular), 'new_item' => sprintf(__('New %s', 'mtphr-galleries'), $singular), 'view_item' => sprintf(__('View %s', 'mtphr-galleries'), $singular), 'search_items' => sprintf(__('Search %s', 'mtphr-galleries'), $plural), 'not_found' => sprintf(__('No %s Found', 'mtphr-galleries'), $plural), 'not_found_in_trash' => sprintf(__('No %s Found in Trash', 'mtphr-galleries'), $plural), 'parent_item_colon' => '', 'menu_name' => sprintf(__('%s', 'mtphr-galleries'), $plural)); // Create the arguments $args = array('labels' => $labels, 'public' => $public, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_icon' => 'dashicons-format-gallery', 'query_var' => true, 'rewrite' => true, 'supports' => array('title', 'thumbnail', 'editor', 'excerpt', 'comments', 'page-attributes'), 'show_in_nav_menus' => true, 'rewrite' => array('slug' => $slug), 'has_archive' => $has_archive); // Register post type register_post_type('mtphr_gallery', $args); }
function mtphr_gallery_settings_render_metabox() { global $post; $settings = mtphr_galleries_settings(); $client = get_post_meta($post->ID, '_mtphr_gallery_client', true); $link = get_post_meta($post->ID, '_mtphr_gallery_link', true); // Filter the tabs $tabs = array('resources' => __('Resources', 'mtphr-galleries'), 'settings' => __('Rotator Settings', 'mtphr-galleries'), 'data' => sprintf(__('%s Data', 'mtphr-galleries'), $settings['singular_label'])); if ($settings['global_slider_settings'] == 'on') { unset($tabs['settings']); } $tabs = apply_filters('mtphr_galleries_tabs', $tabs, $post->post_type); // Filter the data meta $data_meta = apply_filters('mtphr_galleries_data_meta', array('client' => 'client', 'filter' => 'filter', 'external_link' => 'external_link'), $post->post_type); echo '<input type="hidden" name="mtphr_galleries_nonce" value="' . wp_create_nonce(basename(__FILE__)) . '" />'; echo '<div id="mtphr-galleries-page-tabs">'; echo '<ul>'; do_action('mtphr_galleries_metabox_tabs_before', $post->post_type); if (is_array($tabs) && count($tabs) > 0) { foreach ($tabs as $type => $button) { echo '<li class="nav-tab"><a href="#mtphr-galleries-page-tabs-' . $type . '">' . $button . '</a></li>'; } } do_action('mtphr_galleries_metabox_tabs_after', $post->post_type); echo '</ul>'; do_action('mtphr_galleries_metabox_before', $post->post_type); /* --------------------------------------------------------- */ /* !Gallery resources - 1.0.5 */ /* --------------------------------------------------------- */ if (isset($tabs['resources'])) { echo '<div id="mtphr-galleries-page-tabs-resources" class="mtphr-galleries-page-tabs-page">'; mtphr_galleries_resources_metabox(); echo '</div>'; } /* --------------------------------------------------------- */ /* !Rotator settings - 2.0.5 */ /* --------------------------------------------------------- */ if (isset($tabs['settings'])) { echo '<div id="mtphr-galleries-page-tabs-settings" class="mtphr-galleries-page-tabs-page">'; mtphr_galleries_settings_metabox(); echo '</div>'; } /* --------------------------------------------------------- */ /* !Gallery data - 2.0.13 */ /* --------------------------------------------------------- */ if (isset($tabs['data'])) { echo '<div id="mtphr-galleries-page-tabs-data" class="mtphr-galleries-page-tabs-page">'; do_action('mtphr_galleries_data_metabox_before', $post->post_type); echo '<table class="mtphr-galleries-table">'; do_action('mtphr_galleries_data_metabox_top', $post->post_type); // Display the data meta if (is_array($data_meta) && count($data_meta) > 0) { foreach ($data_meta as $i => $meta) { switch ($meta) { case 'client': echo '<tr>'; echo '<td class="mtphr-galleries-label">'; echo '<label>' . __('Client', 'mtphr-galleries') . '</label>'; echo '<small>' . sprintf(__('Add a client to the %s', 'mtphr-galleries'), strtolower($settings['singular_label'])) . '</small>'; echo '</td>'; echo '<td>'; echo '<input type="text" name="_mtphr_gallery_client" value="' . $client . '" />'; echo '</td>'; echo '</tr>'; break; case 'external_link': echo '<tr>'; echo '<td class="mtphr-galleries-label">'; echo '<label>' . __('External link', 'mtphr-galleries') . '</label>'; echo '<small>' . sprintf(__('Add an external link to associate with the %s', 'mtphr-galleries'), strtolower($settings['singular_label'])) . '</small>'; echo '</td>'; echo '<td>'; echo '<input type="text" name="_mtphr_gallery_link" value="' . $link . '" />'; echo '</td>'; echo '</tr>'; break; case 'filter': do_action('mtphr_galleries_data_metabox_middle', $post->post_type); break; default: break; } } } do_action('mtphr_galleries_data_metabox_bottom', $post->post_type); echo '</table>'; do_action('mtphr_galleries_data_metabox_after', $post->post_type); echo '</div>'; } do_action('mtphr_galleries_metabox_after', $post->post_type); echo '</div>'; }
function mtphr_galleries_settings_display() { $settings = mtphr_galleries_settings(); ?> <div class="wrap"> <div id="icon-mtphr_galleries" class="icon32"></div> <h2><?php printf(__('%s Settings', 'mtphr-galleries'), $settings['singular_label']); ?> </h2> <?php settings_errors(); ?> <form method="post" action="options.php"> <?php settings_fields('mtphr_galleries_settings'); do_settings_sections('mtphr_galleries_settings'); submit_button(); ?> </form> </div><!-- /.wrap --> <?php }
/** * 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; }
function mtphr_galleries_init_scripts() { global $mtphr_galleries_scripts; if (is_array($mtphr_galleries_scripts) && !empty($mtphr_galleries_scripts)) { wp_print_scripts('touchSwipe'); wp_print_scripts('jquery-easing'); wp_print_scripts('mtphr-gallery-slider'); ?> <script> jQuery( window ).load( function() { <?php $settings = mtphr_galleries_settings(); if ($settings['global_slider_settings'] == 'on') { ?> jQuery( '.mtphr-gallery' ).mtphr_gallery_slider({ rotate_type : '<?php echo $settings['slider_type']; ?> ', auto_rotate : <?php echo $settings['slider_auto_rotate'] == 'on' ? 1 : 0; ?> , delay : <?php echo intval($settings['slider_delay']); ?> , rotate_pause : <?php echo $settings['slider_pause'] == 'on' ? 1 : 0; ?> , rotate_speed : <?php echo intval($settings['slider_speed']); ?> , rotate_ease : '<?php echo $settings['slider_ease']; ?> ', nav_reverse : <?php echo $settings['slider_directional_nav_reverse'] == 'on' ? 1 : 0; ?> }); <?php } else { ?> <?php foreach ($mtphr_galleries_scripts as $gallery) { ?> jQuery( '#<?php echo $gallery['id']; ?> ' ).mtphr_gallery_slider({ rotate_type : '<?php echo $gallery['rotate_type']; ?> ', auto_rotate : <?php echo $gallery['auto_rotate']; ?> , delay : <?php echo intval($gallery['rotate_delay']); ?> , rotate_pause : <?php echo $gallery['rotate_pause']; ?> , rotate_speed : <?php echo intval($gallery['rotate_speed']); ?> , rotate_ease : '<?php echo $gallery['rotate_ease']; ?> ', nav_reverse : <?php echo $gallery['nav_reverse']; ?> }); <?php } ?> <?php } ?> }); </script> <?php } }