/** * Search for publications. * * @param array $args * @return array */ private function publication_query($args = array()) { $query = array('post_type' => 'seoslides-slideset', 'suppress_filters' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'post_status' => 'publish', 'order' => 'DESC', 'orderby' => 'post_date', 'posts_per_page' => 20); $args['pagenum'] = isset($args['pagenum']) ? absint($args['pagenum']) : 1; if (isset($args['s'])) { $query['s'] = $args['s']; } $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ($args['pagenum'] - 1) : 0; // Run the query $get_posts = new WP_Query(); $posts = $get_posts->query($query); $results = array(); if (0 === $get_posts->post_count) { return $results; } // Populate results foreach ($posts as $post) { // Get the embed ID for the first slide in the presentation $slideset = new SEOSlides_Slideset($post->ID); /** @var SEOSlides_Embed $embed */ $embed = SEOSlides_Module_Provider::get('SEOSlides Embed'); $embed_id = $embed->get_embed_unique_id($post->ID, $slideset->first_slide()->slug); $embed_url = $embed->get_embed_url($post->ID, $slideset->first_slide()->slug); $shortcode = '[seoslides embed_id="' . $embed_id . '"'; $shortcode .= ' script_src="' . preg_replace('/\\/(slides|embeds)\\//', '/embed-script/', $embed_url) . '"'; $shortcode .= ' overview_src="' . get_permalink($post) . '"'; $shortcode .= ' title="' . get_the_title($post) . '"'; $shortcode .= ' site_src="' . get_home_url() . '"'; $shortcode .= ' site_title="' . get_bloginfo('name') . '"'; $shortcode .= ' /]'; $results[] = array('ID' => $post->ID, 'title' => trim(esc_html(strip_tags(get_the_title($post)))), 'shortcode' => esc_attr($shortcode), 'info' => mysql2date(__('Y/m/d'), $post->post_date)); } return $results; }
/** * Check if this is a request to serve an embed script. If so, send it and exit * * @since 0.1 * * @param WP $wp */ public function maybe_do_embed_script($wp) { if (!isset($wp->query_vars['seoslides-embed']) || $wp->query_vars['seoslides-embed'] !== 'script') { return; } $slideset = SEOSlides_Module_Provider::get('SEOSlides Core')->get_slideset(get_queried_object_id()); if (!$slideset) { wp_die(__('That presentation does not exist!', 'seoslides_translate')); } $slide = $this->get_embedded_slide($slideset->slides, get_query_var('seoslides-embed-slide')); $output = wp_cache_get($slideset->ID . ".{$slide->slug}", 'seoslides-embed-scripts'); if (!$output) { ob_start(); $extension = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? 'src.js' : 'min.js'; require SEOSLIDES_PATH . "js/seoslides_embed.{$extension}"; $output = ob_get_clean(); $embed_url = $this->get_embed_url($slideset->ID, $slide->slug); $unique_id = $this->get_embed_unique_id($slideset->ID, $slide->slug); $output = str_replace(array('%%EMBED_ID%%', '%%EMBED_URL%%'), array($unique_id, $embed_url), $output); wp_cache_set($slideset->ID . ".{$slide->slug}", $output, 'seoslides-embed-scripts'); } echo $output; exit; }
/** * Get the first slide object * * @since 0.3 * * @param int $post_id The Slideset ID. * * @return object The current slide object. */ public function get_first_slide($post_id) { $slideset = SEOSlides_Module_Provider::get('SEOSlides Core')->get_slideset($post_id); if ($slideset->slides) { return current(array_values($slideset->slides)); } else { return array('id' => 0, 'slug' => ''); } }
/** * Handle the PDF Importer menu */ public function menu() { // Clear the cache so we can get a fresh count wp_cache_delete('pending-imports', 'counts'); $step = empty($_GET['step']) ? 0 : (int) $_GET['step']; $clear = empty($_GET['clear_cache']) ? false : true; // The user has suggested we clear their cache, so let's do it. if ($clear) { $all_imports = get_posts(array('post_type' => 'seoslides-import', 'post_status' => 'any', 'posts_per_page' => -1)); foreach ($all_imports as $post) { wp_delete_post($post->ID, true); } } if (1 === $step) { $this->handle_upload(); } $api_key = get_option('seoslides_api_key'); $upload_enabled = true; // Build the site domain $url = get_bloginfo('url'); $url = parse_url($url); $domain = $url['host']; if (isset($url['path'])) { $domain .= $url['path']; } $domain = apply_filters('catalyst_domain', $domain); /** @var SEOSlides_Core $core */ $core = SEOSlides_Module_Provider::get('SEOSlides Core'); // If no API key is set, then show an admin notice because we can't actually do anything! if (false === $api_key || empty($api_key)) { $upload_enabled = false; ?> <div class="error"> <p><?php _e('The slide importer requires a license key.', 'seoslides_translate'); ?> <?php _e('Please sign-up for a license key on the <a href="edit.php?post_type=seoslides-slideset&page=seoslides_settings">settings page</a> to proceed.', 'seoslides_translate'); ?> </p> </div> <?php } ?> <?php if ($core->get_subscription_level() < 20) { ?> <div class="updated"> <p><?php _e('You can use a free license key for 3 imports. Upgrade to the <a href="https://seoslides.com/pro">pro version</a> for unlimited imports during the beta.', 'seoslides_translate'); ?> </p> </div> <?php } ?> <div class="wrap"> <?php screen_icon(); ?> <h2> <?php _e('seoslides Importer', 'seoslides_translate'); ?> </h2> <?php $intro = __('Import PowerPoint, Keynote, or other exported to PDF format. Each PDF page is imported as a slide-sized background image. ', 'seoslides_translate'); $intro .= sprintf(__('Watch a video on <a href="%1$s" target="_new">importing</a>, or view the full <a href="%2$s" target="_new">getting started</a> presentation.', 'seoslides_translate'), esc_url('https://seoslides.com/slides/getting-started-seoslides/uploading-video/'), esc_url('https://seoslides.com/slides/getting-started-seoslides/seoslides-intro-videos/')); ?> <p style="margin-bottom: 40px;"><em><?php echo $intro; ?> </em></p> <div class="seoslides-vistoggler"> <h3 class="title"><?php _e('Step 1: Upload PDF file to seoslides for conversion'); ?> <a style="font-weight:normal;font-size:.9em;"> (more info)</a> </h3> <div class="seoslides-vistogglee" style="padding:10px;border:1px solid #ccc;display:none;border-radius:3px;"> <ul> <li><?php printf(__('<a href="%s" target="_new">Instructions for exporting a PDF from Keynote</a>', 'seoslides_translate'), esc_url('http://support.apple.com/kb/HT3697')); ?> </li> <li><?php printf(__('<a href="%s" target="_new">Instructions for exporting a PDF from Powerpoint</a>', 'seoslides_translate'), esc_url('http://office.microsoft.com/en-us/powerpoint-help/save-as-pdf-HA010064992.aspx')); ?> </li> </ul> </div> </div> <div class="narrow"> <?php if (false === $api_key || empty($api_key)) { $settings_url = add_query_arg(array('post_type' => 'seoslides-slideset', 'page' => 'seoslides_settings'), admin_url('edit.php')); ?> <p><?php printf(__('<strong>Please Note</strong>: You will need a license key for this step. Check out the <a href="%s">settings page</a> for info on getting a free key.', 'seoslides_translate'), esc_url($settings_url)); ?> </p> <?php } elseif ($core->get_subscription_level() < 20) { ?> <p><?php _e('<strong>Please Note</strong>: Your free license key is good for 3 pdf conversions. After that, <a href="http://seoslides.com/pro" target="_new">upgrade to PRO</a> for unlimited uploads and other benefits.', 'seoslides_translate'); ?> </p> <?php } ?> <?php $redirect_url = admin_url('edit.php?post_type=seoslides-slideset&page=seoslides_import&step=1'); ?> <?php $api_url = $this->api_root . '/wp-admin/admin-post.php'; ?> <?php $api_url = add_query_arg(array('seoslides-redirect' => urlencode($redirect_url), 'action' => 'pdf-import'), $api_url); ?> <form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url($api_url); ?> "> <p> <label for="email-notification"><?php _e('Email:', 'seoslides_translate'); ?> </label> <?php $current_user = wp_get_current_user(); ?> <input id="email-notification" name="email-notification" type="text" class="regular-text ltr" value="<?php echo esc_attr($current_user->user_email); ?> " /> <span class="seoslides-vistoggler"> <a><?php _e('(optional)', 'seoslides_translate'); ?> </a> <span class="seoslides-vistogglee" style="display:none"> <?php _e('Your email address will only be used to send you an email when import processing is complete.', 'seoslides_translate'); ?> </span> </span> </p> <p> <label for="upload"><?php _e('PDF file (64MB maximum):', 'seoslides_translate'); ?> </label> <input type="file" id="upload" name="import" size="25"<?php echo $upload_enabled ? '' : ' disabled="disabled"'; ?> /> <input id="seoslides-api_key" name="seoslides-api_key" type="hidden" value="<?php echo esc_attr($api_key); ?> " /> <input id="seoslides-redirect" name="seoslides-redirect" type="hidden" value="<?php echo esc_attr($redirect_url); ?> " /> <input id="seoslides-client_domain" name="seoslides-client_domain" type="hidden" value="<?php echo esc_attr($domain); ?> " /> <input id="action" name="action" type="hidden" value="pdf-import" /> </p> <?php submit_button(__('Upload for Conversion', 'seoslides_translate'), 'button', 'submit', false); ?> </form> </div> <div class="seoslides-vistoggler"> <h3 class="title"><?php _e('Step 2: Import to your site', 'seoslides_translate'); ?> <a style="font-weight:normal;font-size:.9em;"> (more info)</a> </h3> <div class="seoslides-vistogglee" style="padding:10px;border:1px solid #ccc;display:none;border-radius: 3px;"> <p><?php _e('Processing can take a while. Kick back, relax, and let the seoslides servers do the heavy lifting to convert your presentation.', 'seoslides_translate'); ?> </p> </div> </div> <?php $pending_count = count(get_posts(array('post_type' => 'seoslides-import', 'post_status' => 'draft'))) - $this->count_imports(); ?> <div class="narrow"> <?php if (0 < $pending_count) { ?> <p> <?php echo sprintf(_n('You currently have %s presentation being processed on the seoslides server.', 'You currently have %s presentations being processed on the seoslides server.', $pending_count, 'seoslides_translate'), $pending_count); ?> </p> <?php $check_imports = sprintf(__('<a ' . (0 !== $pending_count ? '' : 'disabled="disabled"') . ' class="button" href="%s">Check for completed conversions</a>', 'seoslides_translate'), add_query_arg(array('post_type' => 'seoslides-slideset', 'page' => 'seoslides_import'), admin_url('edit.php'))); echo $check_imports; ?> <?php } ?> <?php if (0 === $pending_count || 0 < $this->count_imports()) { ?> <div id="seoslides_import_status"> <p><?php echo $this->get_status(true); ?> </p> </div><!-- #seoslides_import_status --> <input id="seoslides_process" name="seoslides_process" type="submit" class="button" value="<?php _e('Process Imports', 'seoslides_translate'); ?> " <?php disabled(0 === $this->count_imports()); ?> /> <?php } ?> </div> <h3><?php _e('Step 3: Add slide titles and notes, then publish', 'seoslides_translate'); ?> </h3> <div class="narrow"> <p><?php _e('New presentations can be found under “All Presentations” as drafts.', 'seoslides_translate'); ?> </p> <?php $drafts_url = add_query_arg(array('post_type' => 'seoslides-slideset', 'post_status' => 'draft'), admin_url('edit.php')); ?> <a href="<?php echo esc_url($drafts_url); ?> " class="button"><?php _e('View Draft Presentations', 'seoslides_translate'); ?> </a> </div> <?php if (defined('WP_DEBUG') && WP_DEBUG) { ?> <h3 class="title"><?php _e('Debugging Options', 'seoslides_translate'); ?> </h3> <div class="narrow"> <?php $clear_cache_url = add_query_arg(array('post_type' => 'seoslides-slideset', 'page' => 'seoslides_import', 'clear_cache' => 1), admin_url('edit.php')); $all_imports_url = add_query_arg(array('post_type' => 'seoslides-import'), admin_url('edit.php')); ?> <span> <a class="button" href="<?php echo esc_url($clear_cache_url); ?> "><?php _e('Clear import cache', 'seoslides_translate'); ?> </a> <a class="button" href="<?php echo esc_url($all_imports_url); ?> "><?php _e('View All Imports', 'seoslides_translate'); ?> </a> </span> </div> <?php } ?> </div><!-- .wrap --> <?php }
/** * Get a slideset's embed ID * * @return string */ public function get_embed_id() { return SEOSlides_Module_Provider::get('SEOSlides Embed')->get_embed_unique_id($this->ID, $this->first_slide()->slug); }
/** * Render the markup for the embed overlay. * * @uses apply_filters Filters 'seoslides_embed_tabs' passing the tabs array, the Slide instance, and its underlying post. * @uses apply_filters Filters 'seoslides_embed_asides' passing the asides array, the Slide instance, and its underlying post. * @uses apply_filters Filters 'seoslides_embed_actions' passing the button actions array, the Slide instance, and its underlying post. * * @return string Embed overlay markup */ public function render_embed_overlay() { $asides = array(); // Shortcode embed tab and aside $asides['wordpress-embed-instructions'] = '<h2 class="overlay-label">' . sprintf(__('Embed with seoslides: %s', 'seoslides_translate'), esc_html($this->parent('title'))) . '</h2><p>' . __('Install the <span class="pseudolink" onclick="javascript:window.open(\'http://wordpress.org/plugins/seoslides\',\'_blank\');">seoslides plugin</span> on your WordPress site. Then, to embed this presentation from this slide, copy the shortcode below into any post or page.', 'seoslides_translate') . '</p>'; // Script embed tab and aside $asides['script-embed-instructions'] = '<h2 class="overlay-label">' . sprintf(__('Embed: %s', 'seoslides_translate'), esc_html($this->parent('title'))) . '</h2><p>' . __('To embed this presentation from this slide, insert the script tag below where you would like the presentation to appear.', 'seoslides_translate') . '</p>'; // Presenter notes tab and aside $asides['note'] = "<div class='note-container'><h2 class='overlay-label'>" . sprintf(__('Notes: %s', 'seoslides_translate'), esc_html($this->title)) . "</h2>" . (empty($this->presenter_notes) ? __('Notes are not available for this slide.', 'seoslides_translate') : wp_kses_post($this->presenter_notes)) . "</div>"; // Filter asides so other plugins can hook in to add their own overlays $asides = apply_filters('seoslides_embed_asides', $asides, $this, $this->post); // Build out the embed container $embed = '<div class="embed-container">'; reset($asides); $first_item = key($asides); foreach ($asides as $aside_class => $content) { $class = $aside_class . ($aside_class === $first_item ? ' default current' : ''); $embed .= '<aside class="' . $class . '">' . $content . '</aside>'; } $embed_id = SEOSlides_Module_Provider::get('SEOSlides Embed')->get_embed_unique_id($this->post->post_parent, $this->slug); if (!empty($this->presenter_notes)) { $embed .= '<input class="embed-input hidden" data-title="' . get_the_title($this->slideset) . '" data-site="' . get_bloginfo('name') . '" data-siteurl="' . get_bloginfo('url') . '" id="' . $embed_id . '" />'; } else { $embed .= '<input class="embed-input default" data-title="' . get_the_title($this->slideset) . '" data-site="' . get_bloginfo('name') . '" data-siteurl="' . get_bloginfo('url') . '" id="' . $embed_id . '" />'; } $embed .= '</div>'; return $embed; }
/** * Automatically create a post and embed the specified presentation. */ public function post_from_slideset() { $response = array(); $response['success'] = false; if (!wp_verify_nonce($_POST['_nonce'], 'use_in_post')) { wp_send_json($response); } // First, get our embed code $slideset_id = (int) $_POST['slideset']; $slideset = new SEOSlides_Slideset($slideset_id); $embed_id = $slideset->get_embed_id(); $embed_url = SEOSlides_Module_Provider::get('SEOSlides Embed')->get_embed_url($slideset_id, $slideset->first_slide()->slug); $embed = '[seoslides embed_id="' . $embed_id . '"'; $embed .= ' script_src="' . preg_replace('/\\/(slides|embeds)\\//', '/embed-script/', $embed_url) . '"'; $embed .= ' overview_src="' . get_permalink($slideset_id) . '"'; $embed .= ' title="' . get_the_title($slideset_id) . '"'; $embed .= ' site_src="' . get_home_url() . '"'; $embed .= ' site_title="' . get_bloginfo('name') . '"'; $embed .= ' /]'; // Build out the new post $post = wp_insert_post(array('post_status' => 'draft', 'post_type' => 'post', 'post_content' => $embed)); if (is_wp_error($post) || 0 === $post) { wp_send_json($response); } // Build the edit post url $edit_url = admin_url('post.php'); $edit_url = add_query_arg(array('post' => $post, 'action' => 'edit'), $edit_url); $response['success'] = true; $response['data'] = array('post_id' => $post, 'permalink' => get_permalink($post), 'edit_url' => $edit_url); wp_send_json($response); }
*/ global $post; the_post(); $slide_slug = get_query_var('seoslides-slide'); $slideset_bg = '#000'; if (get_query_var('seoslides-embed')) { $slide = get_posts(array('post_parent' => $post->ID, 'post_type' => 'seoslides-slide', 'post_status' => 'publish', 'numberposts' => 1, 'orderby' => 'menu_order', 'order' => 'ASC')); if ($slide) { $slide_slug = $slide[0]->post_name; } unset($slide); } if ('' === $slide_slug) { // Temporarily redirect to the first slide in the presentation /** @var SEOSlides_Slideset $slideset */ $slideset = SEOSlides_Module_Provider::get('SEOSlides Core')->get_slideset($post->ID); $slides = array_filter($slideset->slides, array('SEOSlides_Slide', 'slide_is_published')); if (count($slides) === 0) { SEOSlides_Util::redirect_404(); } reset($slides); $first_id = key($slides); /** @var SEOSlides_Slide $slide */ $slide = $slides[$first_id]; header("HTTP/1.1 307 Temporary Redirect"); header("Location: " . trailingslashit(trailingslashit(get_permalink()) . $slide->slug)); die; } else { // Get the slide based on its slug $found = get_posts(array('name' => $slide_slug, 'post_type' => 'seoslides-slide', 'post_status' => 'publish', 'numberposts' => 1)); if (count($found) === 0) {
/** * Enqueue scripts and styles only for the presentations. */ public function slideset_enqueue_scripts() { if (!is_singular('seoslides-slideset')) { return; } wp_register_script('seoslides-modernizr', SEOSLIDES_URL . 'js/lib/modernizr.js', array(), '2.6.2'); wp_register_script('seoslides-mobile-detect', SEOSLIDES_URL . 'vendor/mobile-detect/mobile-detect.min.js', array(), '0.1.1'); wp_register_script('seoslides-mobile-detect-modernizr', SEOSLIDES_URL . 'vendor/mobile-detect/mobile-detect-modernizr.js', array('seoslides-modernizr', 'seoslides-mobile-detect'), '0.1.1'); // Get presentation theme $theme_name = get_post_meta(get_the_ID(), '_slideset_theme', true); $theme_name = empty($theme_name) ? 'swiss-horizontal' : $theme_name; $all_themes = $this->available_themes(); $theme = isset($all_themes[$theme_name]) ? $all_themes[$theme_name] : $all_themes['swiss-horizontal']; // Styles if (null !== $theme['theme']) { wp_enqueue_style('seoslides-theme-' . $theme_name, $theme['theme'], array('deck', 'deck.menu', 'deck.goto', 'deck.status', 'deck.navigation'), SEOSLIDES_VERSION, 'screen'); } if (null !== $theme['transition']) { wp_enqueue_style('seoslides-transition-' . $theme_name, $theme['transition'], array('deck', 'deck.menu', 'deck.goto', 'deck.status', 'deck.navigation'), SEOSLIDES_VERSION, 'screen'); } wp_enqueue_style('seoslides-front', SEOSLIDES_URL . 'css/front-end.css', array('deck', 'deck.menu', 'deck.goto', 'deck.status', 'deck.navigation'), SEOSLIDES_VERSION, 'screen'); wp_enqueue_style('seoslides-print', SEOSLIDES_URL . 'css/print.css', array(), SEOSLIDES_VERSION, 'print'); wp_register_style('dashicons', SEOSLIDES_URL . 'css/dashicons.css', array(), SEOSLIDES_VERSION); wp_register_style('seoslides-iconography', SEOSLIDES_URL . 'css/seoslides-iconography.css', array(), SEOSLIDES_VERSION); wp_enqueue_style('dashicons'); wp_enqueue_style('seoslides-iconography'); // Video $this->enqueue_mediaelement(); // Scripts $this->enqueue_script('seoslides_front', array('jquery', 'seoslides-mobile-detect-modernizr', 'wp-mediaelement', 'deck', 'deck.menu', 'deck.goto', 'deck.status', 'deck.navigation'), true); $this->script_translations('seoslides_front'); $embedID = ''; if (get_query_var('seoslides-embed')) { $slide = get_query_var('seoslides-embed-slide') ? get_query_var('seoslides-embed-slide') : ''; $embedID = SEOSlides_Module_Provider::get('SEOSlides Embed')->get_embed_unique_id(get_the_ID(), $slide); } wp_localize_script('seoslides_front', 'seoslides', array('ajaxurl' => admin_url('admin-ajax.php'), 'slideset' => get_the_ID(), 'embedID' => $embedID, 'photon_url' => function_exists('jetpack_photon_url') ? 'enabled' : 'disabled')); }