<i class="icon-twitter-square"></i> </a> <a class="social-google" href="https://plus.google.com/share?url=<?php echo esc_url(wp_get_shortlink()); ?> " target="_blank"> <i class="icon-google-plus-square"></i> </a> <a class="social-email" href="mailto:?subject=I wanted to share this post with you from <?php echo esc_url(bloginfo('name')); ?> &body=<?php the_title('', '', true); ?>   <?php echo esc_url(wp_get_shortlink()); ?> " title="Email to a friend"> <i class="icon-envelope"></i> </a> </div> <!-- /social share --> <!-- author bio --> <hr> <div id="author-bio"> <a href="<?php the_author_meta('user_url'); ?> "> <?php
function bctt_shortcode($atts) { extract(shortcode_atts(array('tweet' => '', 'via' => 'yes', 'url' => 'yes'), $atts)); $handle = get_option('bctt-twitter-handle'); if (!empty($handle) && $via != 'no') { $handle_code = "&via=" . $handle . "&related=" . $handle; } else { $handle_code = ''; } $text = $tweet; if ($url != 'no') { if (get_option('bctt-short-url') != false) { $bcttURL = '&url=' . wp_get_shortlink(); } else { $bcttURL = '&url=' . get_permalink(); } } else { $bcttURL = ''; } $bcttBttn = sprintf(__('Click To Tweet', 'better-click-to-tweet')); $short = bctt_shorten($text, 117 - (6 + mb_strlen($handle))); if (!is_feed()) { return "<div class='bctt-click-to-tweet'><span class='bctt-ctt-text'><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . $bcttURL . "' target='_blank'>" . $short . "</a></span><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . "&url=" . $bcttURL . "' target='_blank' class='bctt-ctt-btn'>" . $bcttBttn . "</a></div>"; } else { return "<hr /><p><em>" . $short . "</em><br /><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . $bcttURL . "' target='_blank' class='bctt-ctt-btn'>" . $bcttBttn . "</a><br /><hr />"; } }
/** * Simple tweet button */ function get_stc_tweetbutton($args = '') { global $stc_tweetbutton_defaults; $args = wp_parse_args($args, $stc_tweetbutton_defaults); extract($args); // fix for missing ID in some cases (some shortlink plugins don't work well with ID = zero) if (!$id) { $id = get_the_ID(); } $options = get_option('stc_options'); if ($options['tweetbutton_source']) { $source = $options['tweetbutton_source']; } if ($options['tweetbutton_style']) { $style = $options['tweetbutton_style']; } if ($options['tweetbutton_related']) { $related = $options['tweetbutton_related']; } $url = wp_get_shortlink($id); $counturl = get_permalink($id); $post = get_post($id); $text = esc_attr(strip_tags($post->post_title)); if (!empty($related)) { $datarelated = " data-related='{$related}'"; } $query = http_build_query(array('url' => $url, 'count' => $style, 'related' => $related)); $query .= '&text=' . rawurlencode($text); $out = "<a href='http://twitter.com/share?{$query}' class='twitter-share-button' data-text='{$text}' data-url='{$url}' data-counturl='{$counturl}' data-count='{$style}' data-via='{$source}'{$datarelated}>Tweet</a>"; return $out; }
function wps_post_suggestion($content) { if (is_single()) { global $sms; require_once dirname(__FILE__) . "/../templates/wp-sms-post-suggestion.php"; if ($_POST['send_post']) { $mobile = $_POST['get_fmobile']; if ($_POST['get_name'] && $_POST['get_fname'] && $_POST['get_fmobile']) { if (preg_match("([a-zA-Z])", $mobile) == 0) { $sms->to = array($_POST['get_fmobile']); $template_vars = array('post_title' => get_the_title(), 'sms_sender' => $_POST['get_name'], 'sms_receiver' => $_POST['get_fname'], 'post_shortlink' => wp_get_shortlink()); $string = get_option('wpsms_suggestion_tt'); $final_message = preg_replace('/%(.*?)%/ime', "\$template_vars['\$1']", $string); $sms->msg = $final_message; if ($sms->SendSMS()) { _e('SMS was sent with success', 'wp-sms'); } } else { _e('Please enter a valid mobile number', 'wp-sms'); } } else { _e('Please complete all fields', 'wp-sms'); } } } return $content; }
function googl_custom_columns( $column ) { if ( 'shortlink' == $column ) { $shorturl = wp_get_shortlink(); $shorturl_caption = str_replace( 'http://', '', $shorturl ); $shorturl_info = str_replace( 'goo.gl/', 'goo.gl/info/', $shorturl ); printf( '<a href="%s">%s</a> (<a href="%s">info</a>)', esc_url( $shorturl ), esc_html( $shorturl_caption ), esc_url( $shorturl_info ) ); } }
/** * Callback for add_meta_boxes-{posttype} */ function wpbitly_add_metaboxes($post) { global $post; $shortlink = wp_get_shortlink(); if (empty($shortlink)) { return; } add_meta_box('wpbitly-meta', 'WP Bit.ly', 'wpbitly_build_metabox', $post->post_type, 'side', 'default', array($shortlink)); }
/** * @ticket 26871 */ function test_wp_get_shortlink_with_home_page() { $post_id = self::factory()->post->create(array('post_type' => 'page')); update_option('show_on_front', 'page'); update_option('page_on_front', $post_id); $this->assertEquals(home_url('/'), wp_get_shortlink($post_id, 'post')); $this->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/'); $this->assertEquals(home_url('/'), wp_get_shortlink($post_id, 'post')); }
function ativista_share_twitter($atts, $content = null) { $a = shortcode_atts(array('text' => ''), $atts); if (!empty($atts['text'])) { $twitter_text = $atts['text'] . ' ' . wp_get_shortlink(); } else { $twitter_text = wp_get_shortlink(); } return '<a href="https://twitter.com/intent/tweet?text=' . $twitter_text . ' " class="content-button content-button-twitter icon-twitter" target="_blank">' . do_shortcode($content) . '</a>'; }
public function get_rows_social_preview(&$form, &$head_info) { $rows = array(); $prev_width = 600; $prev_height = 315; $div_style = 'width:' . $prev_width . 'px; height:' . $prev_height . 'px;'; $have_sizes = !empty($head_info['og:image:width']) && $head_info['og:image:width'] > 0 && !empty($head_info['og:image:height']) && $head_info['og:image:height'] > 0 ? true : false; $is_sufficient = $have_sizes === true && $head_info['og:image:width'] >= $prev_width && $head_info['og:image:height'] >= $prev_height ? true : false; foreach (array('og:image:secure_url', 'og:image') as $img_url) { if (!empty($head_info[$img_url])) { if ($have_sizes === true) { $image_preview_html = '<div class="preview_img" style="' . $div_style . ' background-size:' . ($is_sufficient === true ? 'cover' : $head_info['og:image:width'] . ' ' . $head_info['og:image:height']) . '; background-image:url(' . $head_info[$img_url] . ');" />' . ($is_sufficient === true ? '' : '<p>' . sprintf(_x('Image Dimensions Smaller<br/>than Suggested Minimum<br/>of %s', 'preview image error', 'nextgen-facebook'), $prev_width . 'x' . $prev_height . 'px') . '</p>') . '</div>'; } else { $image_preview_html = '<div class="preview_img" style="' . $div_style . ' background-image:url(' . $head_info[$img_url] . ');" /><p>' . _x('Image Dimensions Unknown<br/>or Not Available', 'preview image error', 'nextgen-facebook') . '</p></div>'; } break; // stop after first image } } if (empty($image_preview_html)) { $image_preview_html = '<div class="preview_img" style="' . $div_style . '"><p>' . _x('No Open Graph Image Found', 'preview image error', 'nextgen-facebook') . '</p></div>'; } $long_url = $this->p->util->get_sharing_url($head_info['post_id']); $short_url = apply_filters($this->p->cf['lca'] . '_shorten_url', $long_url, $this->p->options['plugin_shortener']); if ($long_url === $short_url && SucomUtil::is_post_page()) { $short_url = wp_get_shortlink(); } $rows[] = $this->p->util->get_th(_x('Sharing URL', 'option label', 'nextgen-facebook'), 'medium') . '<td>' . $form->get_copy_input($long_url) . '</td>'; $rows[] = $this->p->util->get_th(_x('Short URL', 'option label', 'nextgen-facebook'), 'medium') . '<td>' . $form->get_copy_input($short_url) . '</td>'; $rows[] = $this->p->util->get_th(_x('Open Graph Example', 'option label', 'nextgen-facebook'), 'medium') . '<td rowspan="2" style="background-color:#e9eaed;border:1px dotted #e0e0e0;"> <div class="preview_box" style="width:' . ($prev_width + 40) . 'px;"> <div class="preview_box" style="width:' . $prev_width . 'px;"> ' . $image_preview_html . ' <div class="preview_txt"> <div class="preview_title">' . (empty($head_info['og:title']) ? 'No Title' : $head_info['og:title']) . '</div> <div class="preview_desc">' . (empty($head_info['og:description']) ? 'No Description' : $head_info['og:description']) . '</div> <div class="preview_by">' . ($_SERVER['SERVER_NAME'] . (empty($head_info['author']) ? '' : ' | By ' . $head_info['author'])) . '</div> </div> </div> </div></td>'; $rows[] = '<th class="medium textinfo">' . $this->p->msgs->get('info-meta-social-preview') . '</th>'; return $rows; }
function wp_sms_subscribe_send($wp_sms_new_status = NULL, $wp_sms_old_status = NULL, $post = NULL) { if ($_REQUEST['wps_send_subscribe'] == 'yes') { if ('publish' == $wp_sms_new_status && 'publish' != $wp_sms_old_status) { global $wpdb, $table_prefix, $sms, $wps_options; if ($_REQUEST['wps_subscribe_group'] == 'all') { $sms->to = $wpdb->get_col("SELECT mobile FROM {$table_prefix}sms_subscribes"); } else { $sms->to = $wpdb->get_col("SELECT mobile FROM {$table_prefix}sms_subscribes WHERE group_ID = '{$_REQUEST['wps_subscribe_group']}'"); } $template_vars = array('title_post' => get_the_title($post->ID), 'url_post' => wp_get_shortlink($post->ID), 'date_post' => get_post_time('Y-m-d', true, $post->ID, true)); $sms->msg = preg_replace('/%(.*?)%/ime', "\$template_vars['\$1']", $_REQUEST['wps_custom_text']); $sms->SendSMS(); } } return $post; }
function add_copyright_text() { if (is_single()) { ?> <script type='text/javascript'> function addLink() { if ( window.getSelection().containsNode( document.getElementsByClassName('entry-content')[0], true)) { var body_element = document.getElementsByTagName('body')[0]; var selection; selection = window.getSelection(); var oldselection = selection var pagelink = "<br /><br /> Read more at WPBeginner: <?php the_title(); ?> <a href='<?php echo wp_get_shortlink(get_the_ID()); ?> '><?php echo wp_get_shortlink(get_the_ID()); ?> </a>"; //Change this if you like var copy_text = selection + pagelink; var new_div = document.createElement('div'); new_div.style.left='-99999px'; new_div.style.position='absolute'; body_element.appendChild(new_div ); new_div.innerHTML = copy_text ; selection.selectAllChildren(new_div ); window.setTimeout(function() { body_element.removeChild(new_div ); },0); } } document.oncopy = addLink; </script> <?php } }
function wp_sms_subscribe_send($wp_sms_new_status = NULL, $wp_sms_old_status = NULL, $post_ID = NULL) { if ($_REQUEST['subscribe_post'] == 'yes') { if ('publish' == $wp_sms_new_status && 'publish' != $wp_sms_old_status) { global $wpdb, $table_prefix, $sms; $sms->to = $wpdb->get_col("SELECT mobile FROM {$table_prefix}sms_subscribes"); $string = get_option('wp_sms_text_template'); $template_vars = array('title_post' => get_the_title($post_ID), 'url_post' => wp_get_shortlink($post_ID), 'date_post' => get_post_time(get_option('date_format'), true, $post_ID)); $final_message = preg_replace('/%(.*?)%/ime', "\$template_vars['\$1']", $string); if (get_option('wp_sms_text_template')) { $sms->msg = $final_message; } else { $sms->msg = get_the_title($post_ID); } $sms->SendSMS(); } } return $post_ID; }
/** * Muestra botones para compartir una página. * @param array $atts Redes sociales el * @return [type] [description] */ function shortcodeCompartir($atts = array()) { $args = shortcode_atts(array('mostrar' => 'facebook,twitter,googleplus,whatsapp'), $atts); $redesMostradas = explode(',', $args['mostrar']); $retorno = array(); // Clase del tag, url, nombre, contenido del tag $formato = '<a class="%s" href="%s" onclick="return !window.open(this.href, \'%s\', \'width=640,height=580\')">%s</a>'; // Se los pasa por un loop para poder elegir el orden desde el shortcode. $permalink = get_the_permalink(); $shortlink = wp_get_shortlink(); foreach ($redesMostradas as $item) { if ($item == 'facebook') { $nombre = 'Facebook'; $contenido = retornarSVG('facebook'); $query = http_build_query(array('u' => $permalink, 'display' => 'popup', 'ref' => 'plugin', 'src' => 'share_button')); $url = 'https://www.facebook.com/sharer/sharer.php?' . $query; $retorno[] = sprintf($formato, 'compartir ' . $item, $url, $nombre, $contenido); } if ($item == 'twitter') { $nombre = 'Twitter'; $contenido = retornarSVG('twitter'); $query = http_build_query(array('status' => $shortlink)); $url = 'https://twitter.com/home?' . $query; $retorno[] = sprintf($formato, 'compartir ' . $item, $url, $nombre, $contenido); } if ($item == 'googleplus') { $nombre = 'Google Plus'; $contenido = retornarSVG('google-plus'); $query = http_build_query(array('url' => get_the_permalink())); $url = 'https://plus.google.com/share?'; $retorno[] = sprintf($formato, 'compartir ' . $item, $url . $query, $nombre, $contenido); } if ($item == 'whatsapp') { $nombre = 'WhatsApp'; $contenido = retornarSVG('whatsapp'); $query = http_build_query(array('text' => get_the_permalink())); $url = 'whatsapp://send?' . $query; $retorno[] = sprintf('<a class="%s" href="%s" rel="nofollow">%s</a>', 'compartir ' . $item, $url, $contenido); } } return implode('', $retorno); }
function get_QR_code($atts, $content = null) { extract(shortcode_atts(array('size' => '150x150', 'ImgTag' => 'yes', 'link' => 'no'), $atts)); if ($size == null) { $size = '150x150'; } if ($content == null) { $content = wp_get_shortlink(); } $content = urlencode($content); if ($ImgTag == 'yes') { if ($link == 'yes') { return '<a href="' . urldecode($content) . '"><img src="http://chart.apis.google.com/chart?cht=qr&chs=' . $size . '&choe=UTF-8&chld=H&chl=' . $content . '"></a>'; } else { return '<img src="http://chart.apis.google.com/chart?cht=qr&chs=' . $size . '&choe=UTF-8&chld=H&chl=' . $content . '">'; } } else { return 'http://chart.apis.google.com/chart?cht=qr&chs=' . $size . '&choe=UTF-8&chld=H&chl=' . $content; } }
function jawsdays_publicize_save_meta($submit_post, $post_id, $service_name, $connection) { $suffix = " #jawsdays #jawsug"; $title = get_the_title($post_id); $link = wp_get_shortlink($post_id); $publicize_custom_message = get_post_meta($post_id, '_wpas_mess', true); if (empty($publicize_custom_message)) { $publicize_custom_message = sprintf("%s %s %s", $title, $link, $suffix); } else { if (strpos($publicize_custom_message, $title) === false) { $publicize_custom_message = $publicize_custom_message . $title; } if (strpos($publicize_custom_message, $link) === false) { $publicize_custom_message = $publicize_custom_message . $link; } if (strpos($publicize_custom_message, $suffix) === false) { $publicize_custom_message = $publicize_custom_message . $suffix; } } update_post_meta($post_id, '_wpas_mess', $publicize_custom_message); }
/** * Show social links on post using the permalink. */ function bcom_social_links() { ?> <ul class="social-sharing" id="social-sharing"> <li class="facebook"><a href="http://www.facebook.com/share.php?u=<?php echo wp_get_shortlink(); ?> &title=<?php echo get_the_title(); ?> " data-title="<?php echo get_the_title(); ?> " title="Share on Facebook">Share on Facebook</a></li> <li class="twitter"><a href="http://twitter.com/home?status=<?php echo get_the_title(); ?> +<?php echo wp_get_shortlink(); ?> " data-title="<?php echo get_the_title(); ?> " title="Share on Twitter">Share on Twitter</a></li> <li class="linkedin"><a href="http://www.linkedin.com/shareArticle?mini=true&url=<?php echo wp_get_shortlink(); ?> &title=<?php echo get_the_title(); ?> " data-title="<?php echo get_the_title(); ?> " title="Share on LinkedIn">Share on LinkedIn</a></li> </ul> <?php }
function wp_tell_a_freind($content) { if (is_single()) { global $sms; include_once dirname(__FILE__) . "/includes/templates/wp-sms-tell-friend.php"; if ($_POST['send_post']) { $mobile = $_POST['get_fmobile']; if ($_POST['get_name'] && $_POST['get_fname'] && $_POST['get_fmobile']) { if (strlen($mobile) >= 11 && preg_match("([a-zA-Z])", $mobile) == 0) { $sms->to = array($_POST['get_fmobile']); $sms->msg = sprintf(__('Hi %s, the %s post suggested to you by %s. url: %s', 'wp-sms'), $_POST['get_fname'], get_the_title(), $_POST['get_name'], wp_get_shortlink()); if ($sms->SendSMS()) { _e('SMS was sent with success', 'wp-sms'); } } else { _e('Please enter a valid mobile number', 'wp-sms'); } } else { _e('Please complete all fields', 'wp-sms'); } } } return $content; }
function o2_get_default_post_actions($actions = false, $post_ID = false) { if (false === $actions) { $actions = array(); } // Reply $logged_in_requirement_satisfied = get_option('comment_registration') ? is_user_logged_in() : true; if (comments_open($post_ID) && !post_password_required($post_ID) && $logged_in_requirement_satisfied) { $actions[20] = array('action' => 'reply', 'href' => get_permalink($post_ID) . '#respond', 'classes' => array('o2-post-reply', 'o2-reply'), 'rel' => false, 'initialState' => 'default'); } // Scroll to Comments (Mobile) $actions[25] = array('action' => 'scrolltocomments', 'href' => get_permalink($post_ID), 'classes' => array('o2-scroll-to-comments'), 'rel' => false, 'initialState' => 'default'); // Edit if (current_user_can('edit_post', $post_ID)) { $actions[30] = array('action' => 'edit', 'href' => get_edit_post_link($post_ID), 'classes' => array('edit-post-link', 'o2-edit'), 'rel' => $post_ID, 'initialState' => 'default'); } // Trash if (current_user_can('edit_post', $post_ID)) { $actions[100] = array('action' => 'trash', 'href' => get_delete_post_link($post_ID), 'classes' => array('trash-post-link', 'o2-trash', 'o2-actions-border-top', 'o2-warning-hover'), 'rel' => $post_ID, 'initialState' => 'default'); } // Shortlink $actions[40] = array('action' => 'shortlink', 'href' => wp_get_shortlink($post_ID, 'post'), 'classes' => array('short-link', 'o2-short-link'), 'rel' => false, 'initialState' => 'default'); return $actions; }
function get_comment($comment_id, $context) { global $blog_id; $comment = get_comment($comment_id); if (!$comment || is_wp_error($comment)) { return new WP_Error('unknown_comment', 'Unknown comment', 404); } $types = array('', 'comment', 'pingback', 'trackback'); if (!in_array($comment->comment_type, $types)) { return new WP_Error('unknown_comment', 'Unknown comment', 404); } $post = get_post($comment->comment_post_ID); if (!$post || is_wp_error($post)) { return new WP_Error('unknown_post', 'Unknown post', 404); } $status = wp_get_comment_status($comment->comment_ID); // Permissions switch ($context) { case 'edit': if (!current_user_can('edit_comment', $comment->comment_ID)) { return new WP_Error('unauthorized', 'User cannot edit comment', 403); } $GLOBALS['post'] = $post; $comment = get_comment_to_edit($comment->comment_ID); foreach (array('comment_author', 'comment_author_email', 'comment_author_url') as $field) { $comment->{$field} = htmlspecialchars_decode($comment->{$field}, ENT_QUOTES); } break; case 'display': if ('approved' !== $status) { $current_user_id = get_current_user_id(); $user_can_read_coment = false; if ($current_user_id && $comment->user_id && $current_user_id == $comment->user_id) { $user_can_read_coment = true; } elseif ($comment->comment_author_email && $comment->comment_author && isset($this->api->token_details['user']) && isset($this->api->token_details['user']['user_email']) && $this->api->token_details['user']['user_email'] === $comment->comment_author_email && $this->api->token_details['user']['display_name'] === $comment->comment_author) { $user_can_read_coment = true; } else { $user_can_read_coment = current_user_can('edit_comment', $comment->comment_ID); } if (!$user_can_read_coment) { return new WP_Error('unauthorized', 'User cannot read unapproved comment', 403); } } $GLOBALS['post'] = $post; setup_postdata($post); break; default: return new WP_Error('invalid_context', 'Invalid API CONTEXT', 400); } $can_view = $this->user_can_view_post($post->ID); if (!$can_view || is_wp_error($can_view)) { return $can_view; } $GLOBALS['comment'] = $comment; $response = array(); foreach (array_keys($this->comment_object_format) as $key) { switch ($key) { case 'ID': // explicitly cast all output $response[$key] = (int) $comment->comment_ID; break; case 'post': $response[$key] = (object) array('ID' => (int) $post->ID, 'title' => (string) get_the_title($post->ID), 'type' => (string) $post->post_type, 'link' => (string) $this->links->get_post_link($this->api->get_blog_id_for_output(), $post->ID)); break; case 'author': $response[$key] = (object) $this->get_author($comment, 'edit' === $context && current_user_can('edit_comment', $comment->comment_ID)); break; case 'date': $response[$key] = (string) $this->format_date($comment->comment_date_gmt, $comment->comment_date); break; case 'URL': $response[$key] = (string) esc_url_raw(get_comment_link($comment->comment_ID)); break; case 'short_URL': // @todo - pagination $response[$key] = (string) esc_url_raw(wp_get_shortlink($post->ID) . "%23comment-{$comment->comment_ID}"); break; case 'content': if ('display' === $context) { ob_start(); comment_text(); $response[$key] = (string) ob_get_clean(); } else { $response[$key] = (string) $comment->comment_content; } break; case 'status': $response[$key] = (string) $status; break; case 'parent': // (object|false) if ($comment->comment_parent) { $parent = get_comment($comment->comment_parent); $response[$key] = (object) array('ID' => (int) $parent->comment_ID, 'type' => (string) ($parent->comment_type ? $parent->comment_type : 'comment'), 'link' => (string) $this->links->get_comment_link($blog_id, $parent->comment_ID)); } else { $response[$key] = false; } break; case 'type': $response[$key] = (string) ($comment->comment_type ? $comment->comment_type : 'comment'); break; case 'like_count': if (defined('IS_WPCOM') && IS_WPCOM) { $response[$key] = (int) $this->api->comment_like_count($blog_id, $post->ID, $comment->comment_ID); } break; case 'i_like': if (defined('IS_WPCOM') && IS_WPCOM) { $response[$key] = (bool) Likes::comment_like_current_user_likes($blog_id, $comment->comment_ID); } break; case 'meta': $response[$key] = (object) array('links' => (object) array('self' => (string) $this->links->get_comment_link($this->api->get_blog_id_for_output(), $comment->comment_ID), 'help' => (string) $this->links->get_comment_link($this->api->get_blog_id_for_output(), $comment->comment_ID, 'help'), 'site' => (string) $this->links->get_site_link($this->api->get_blog_id_for_output()), 'post' => (string) $this->links->get_post_link($this->api->get_blog_id_for_output(), $comment->comment_post_ID), 'replies' => (string) $this->links->get_comment_link($this->api->get_blog_id_for_output(), $comment->comment_ID, 'replies/'), 'likes' => (string) $this->links->get_comment_link($this->api->get_blog_id_for_output(), $comment->comment_ID, 'likes/'))); break; } } unset($GLOBALS['comment'], $GLOBALS['post']); return $response; }
/** * Fires before the permalink field in the edit form. * * @since 4.1.0 * * @param WP_Post $post Post object. */ do_action('edit_form_before_permalink', $post); ?> <div class="inside"> <?php if ($viewable) { $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : ''; // As of 4.4, the Get Shortlink button is hidden by default. if (has_filter('pre_get_shortlink') || has_filter('get_shortlink')) { $shortlink = wp_get_shortlink($post->ID, 'post'); if (!empty($shortlink) && $shortlink !== $permalink && $permalink !== home_url('?page_id=' . $post->ID)) { $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>'; } } if ($post_type_object->public && !('pending' == get_post_status($post) && !current_user_can($post_type_object->cap->publish_posts))) { $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status; ?> <div id="edit-slug-box" class="hide-if-no-js"> <?php if ($has_sample_permalink) { echo $sample_permalink_html; } ?> </div> <?php
/** * Shortcode for Social Counter. */ function the_champ_counter_shortcode($params) { // notify if counter is disabled if (the_champ_social_counter_enabled()) { extract(shortcode_atts(array('style' => '', 'type' => 'horizontal', 'left' => '0', 'right' => '0', 'top' => '100', 'url' => '', 'align' => 'left', 'title' => ''), $params)); if ($type == 'horizontal' && !the_champ_horizontal_counter_enabled() || $type == 'vertical' && !the_champ_vertical_counter_enabled()) { return; } global $post; if ($url) { $targetUrl = $url; $postId = 0; } elseif (is_front_page()) { $targetUrl = site_url(); $postId = 0; } elseif (get_permalink($post->ID)) { $targetUrl = get_permalink($post->ID); $postId = $post->ID; } else { $targetUrl = html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"])); $postId = 0; } $alignmentOffset = 0; if ($left) { $alignmentOffset = $left; } elseif ($right) { $alignmentOffset = $right; } global $theChampCounterOptions; $html = '<div class="the_champ_counter_container the_champ_' . $type . '_counter' . ($type == 'vertical' && isset($theChampCounterOptions['hide_mobile_likeb']) ? ' the_champ_hide_sharing' : '') . '" ss-offset="' . $alignmentOffset . '" '; $verticalOffsets = ''; if ($type == 'vertical') { $verticalOffsets = $align . ': ' . ${$align} . 'px; top: ' . $top . 'px;'; } // style if ($style != "" || $verticalOffsets != '') { $html .= 'style="'; if (strpos($style, 'background') === false) { $html .= '-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;'; } $html .= $verticalOffsets; $html .= $style; $html .= '"'; } $html .= '>'; if ($type == 'horizontal' && $title != '') { $html .= '<div style="font-weight:bold">' . ucfirst($title) . '</div>'; } $counterUrl = $targetUrl; if (isset($theChampCounterOptions['use_shortlinks']) && function_exists('wp_get_shortlink')) { $counterUrl = wp_get_shortlink(); // if bit.ly integration enabled, generate bit.ly short url } elseif (isset($theChampCounterOptions['bitly_enable']) && isset($theChampCounterOptions['bitly_username']) && isset($theChampCounterOptions['bitly_username']) && $theChampCounterOptions['bitly_username'] != '' && isset($theChampCounterOptions['bitly_key']) && $theChampCounterOptions['bitly_key'] != '') { $shortUrl = the_champ_generate_counter_bitly_url($targetUrl, $postId); if ($shortUrl) { $counterUrl = $shortUrl; } } $html .= the_champ_prepare_counter_html($targetUrl, $type, $counterUrl); $html .= '</div>'; return $html; } }
/** * Display the Short Link for a Post * * Must be called from inside "The Loop" * * Call like the_shortlink(__('Shortlinkage FTW')) * * @since 3.0.0 * * @param string $text Optional The link text or HTML to be displayed. Defaults to 'This is the short link.' * @param string $title Optional The tooltip for the link. Must be sanitized. Defaults to the sanitized post title. * @param string $before Optional HTML to display before the link. * @param string $after Optional HTML to display after the link. */ function the_shortlink($text = '', $title = '', $before = '', $after = '') { $post = get_post(); if (empty($text)) { $text = __('This is the short link.'); } if (empty($title)) { $title = the_title_attribute(array('echo' => false)); } $shortlink = wp_get_shortlink($post->ID); if (!empty($shortlink)) { $link = '<a rel="shortlink" href="' . esc_url($shortlink) . '" title="' . $title . '">' . $text . '</a>'; /** * Filter the shortlink anchor tag for a post. * * @since 3.0.0 * * @param string $link Shortlink anchor tag. * @param string $shortlink Shortlink URL. * @param string $text Shortlink's text. * @param string $title Shortlink's title attribute. */ $link = apply_filters('the_shortlink', $link, $shortlink, $text, $title); echo $before, $link, $after; } }
/** * Provide a shortlink. * * @since 3.1.0 * * @param WP_Admin_Bar $wp_admin_bar */ function wp_admin_bar_shortlink_menu($wp_admin_bar) { $short = wp_get_shortlink(0, 'query'); $id = 'get-shortlink'; if (empty($short)) { return; } $html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr($short) . '" />'; $wp_admin_bar->add_menu(array('id' => $id, 'title' => __('Shortlink'), 'href' => $short, 'meta' => array('html' => $html))); }
/** * Get a post and associated data in the standard JP format. * Cannot be called statically * * @param int $id Post ID * @return Array containing full post details */ function get_post($id) { $post_obj = get_post($id); if (!$post_obj) { return false; } if (is_callable($post_obj, 'to_array')) { // WP >= 3.5 $post = $post_obj->to_array(); } else { // WP < 3.5 $post = get_object_vars($post_obj); } if (0 < strlen($post['post_password'])) { $post['post_password'] = '******' . wp_generate_password(10, false); // We don't want the real password. Just pass something random. } // local optimizations unset($post['filter'], $post['ancestors'], $post['post_content_filtered'], $post['to_ping'], $post['pinged']); if ($this->is_post_public($post)) { $post['post_is_public'] = Jetpack::get_option('public'); } else { //obscure content $post['post_content'] = ''; $post['post_excerpt'] = ''; $post['post_is_public'] = false; } $post_type_obj = get_post_type_object($post['post_type']); $post['post_is_excluded_from_search'] = $post_type_obj->exclude_from_search; $post['tax'] = array(); $taxonomies = get_object_taxonomies($post_obj); foreach ($taxonomies as $taxonomy) { $terms = get_object_term_cache($post_obj->ID, $taxonomy); if (empty($terms)) { $terms = wp_get_object_terms($post_obj->ID, $taxonomy); } $term_names = array(); foreach ($terms as $term) { $term_names[] = $term->name; } $post['tax'][$taxonomy] = $term_names; } $meta = get_post_meta($post_obj->ID, false); $post['meta'] = array(); foreach ($meta as $key => $value) { $post['meta'][$key] = array_map('maybe_unserialize', $value); } $post['extra'] = array('author' => get_the_author_meta('display_name', $post_obj->post_author), 'author_email' => get_the_author_meta('email', $post_obj->post_author)); if ($fid = get_post_thumbnail_id($id)) { $feature = wp_get_attachment_image_src($fid, 'large'); if (!empty($feature[0])) { $post['extra']['featured_image'] = $feature[0]; } } $post['permalink'] = get_permalink($post_obj->ID); $post['shortlink'] = wp_get_shortlink($post_obj->ID); return $post; }
if (have_posts()) { while (have_posts()) { the_post(); $category = get_the_category($post->ID); foreach ($category as $cat) { echo '<div class="entry-content post ' . $cat->slug . ' row">'; echo '<div class="post-icon large-2 hide-for-medium hide-for-small columns"><i title="' . $cat->name . '"></i><span class="icon-text">' . $cat->name . '</span><div class="hack-num">#' . $post->ID . '</div></div>'; echo '<div class="post-text large-10 medium-12 small-12 columns">'; echo '<a href="' . get_permalink($post->ID) . '">' . my_excerpt(35) . '</a>'; if (get_field('submitted_by', $post->ID)) { echo '<div class="submitted-wrap"><div class="submitted-by">Submitted By ' . get_field('submitted_by', $post->ID) . '</div></div>'; } echo do_shortcode('[simple-social-share]'); echo '<a class="tweet" href="https://twitter.com/intent/tweet?text=' . substr(strip_tags(get_the_content()), 0, 75) . '...&hashtags=babylifehacks,parenting,parentingtips&url=' . wp_get_shortlink() . '" target="_blank">Tweet</a>'; echo '<a class="mail" href="mailto:?subject=' . substr(strip_tags(get_the_content()), 0, 75) . '...&body=' . substr(strip_tags(get_the_content()), 0, 75) . '...Read the rest of this tip on BabyLifeHacks.com here: ' . wp_get_shortlink() . '">Mail</a>'; echo '<div class="url"><a href="' . wp_get_shortlink() . '" target="_blank"><span title="' . wp_get_shortlink() . '"></span></a></div>'; echo '<div class="comments">Comments: <fb:comments-count href="' . get_permalink($post->ID) . '"></fb:comments-count></div>'; $image = get_field('hack_image', $post->ID); if (!empty($image)) { ?> <a class="hack-image-link" href="<?php echo get_permalink($post->ID); ?> "><img class="hack-image" src="<?php echo $image['url']; ?> " alt="<?php echo substr(strip_tags(get_the_content()), 0, 75); ?> " /></a> <?php
/** * Display the Short Link for a Post * * Must be called from inside "The Loop" * * Call like the_shortlink(__('Shortlinkage FTW')) * * @since 3.0.0 * * @param string $text Optional The link text or HTML to be displayed. Defaults to 'This is the short link.' * @param string $title Optional The tooltip for the link. Must be sanitized. Defaults to the sanitized post title. * @param string $before Optional HTML to display before the link. * @param string $before Optional HTML to display after the link. */ function the_shortlink($text = '', $title = '', $before = '', $after = '') { global $post; if (empty($text)) { $text = __('This is the short link.'); } if (empty($title)) { $title = the_title_attribute(array('echo' => FALSE)); } $shortlink = wp_get_shortlink($post->ID); if (!empty($shortlink)) { $link = '<a rel="shortlink" href="' . esc_url($shortlink) . '" title="' . $title . '">' . $text . '</a>'; $link = apply_filters('the_shortlink', $link, $shortlink, $text, $title); echo $before, $link, $after; } }
?> <?php //echo $product->get_tags( ', ', '<span class="tagged_as">' . _n( 'Tag:', 'Tags:', $tag_count, 'woocommerce' ) . ' ', '.</span>' ); ?> <?php do_action('woocommerce_product_meta_end'); ?> <?php // Post Url $permalink = get_permalink(); // Short Link for Twitter $shortlink = wp_get_shortlink(); // Post title $title = get_the_title(); // Description $excerpt = get_the_excerpt(); // Featured Image $thumb_id = get_post_thumbnail_id(); // Large Image $image_large_url_array = wp_get_attachment_image_src($thumb_id, 'large', true); $image_large_url = $image_large_url_array[0]; // Thumb Image //$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail', true); //$thumb_url = $thumb_url_array[0]; /* Facebook ______________________ */
/** * Main share box that is displayed on the page * * @param string $id post/page/download ID * @param string $title custom title * @param string $message custom message * @param string $tweet custom tweet message * @return void * @since 2.0 */ function edd_wl_sharing_services() { global $edd_options; // get list ID $list_id = get_query_var('wl_view'); $sharing_layout = apply_filters('edd_wl_sharing_layout', 'vertical'); if ('vertical' == $sharing_layout) { $twitter_layout = 'data-count="vertical"'; $facebook_layout = 'data-layout="box_count"'; $googleplus_layout = 'data-size="tall"'; $linkedin_layout = 'data-counter="top"'; } elseif ('horizontal' == $sharing_layout) { $twitter_layout = 'data-count="horizontal"'; $facebook_layout = 'data-layout="button_count"'; $googleplus_layout = 'data-size="medium"'; $linkedin_layout = 'data-counter="right"'; } else { $twitter_layout = ''; $facebook_layout = ''; $googleplus_layout = ''; $linkedin_layout = ''; } // twitter message $twitter_text = apply_filters('edd_wl_twitter_text', get_the_title($list_id)); // URL to share. Uses shortlink $share_url = apply_filters('edd_wl_share_url', wp_get_shortlink(get_query_var('wl_view'))); // get services $services = edd_get_option('edd_wl_services', ''); // return if there are no services if (empty($services)) { return; } ob_start(); ?> <div class="<?php echo apply_filters('edd_wl_share_classes', 'edd-wl-share'); ?> "> <?php do_action('edd_wl_before_share_box'); ?> <?php if (edd_wl_sharing_is_enabled('twitter')) { $locale = apply_filters('edd_wl_twitter_locale', 'en'); $twitter_button_size = apply_filters('edd_wl_twitter_button_size', 'medium'); ?> <div class="edd-wl-service twitter"> <a href="https://twitter.com/share" data-width="100" data-lang="<?php echo $locale; ?> " class="twitter-share-button" <?php echo $twitter_layout; ?> data-size="<?php echo $twitter_button_size; ?> " data-counturl="<?php echo post_permalink(get_query_var('wl_view')); ?> " data-url="<?php echo $share_url; ?> " data-text="<?php echo $twitter_text; ?> " data-related=""><?php _e('Share', 'edd-wish-lists'); ?> </a> </div> <?php } ?> <?php if (edd_wl_sharing_is_enabled('facebook')) { $data_share = apply_filters('edd_wl_facebook_share_button', 'false'); $layout = isset($sharing_layout) ? 'data-layout="' . $sharing_layout . '"' : ''; ?> <div class="edd-wl-service facebook"> <div class="fb-like" data-href="<?php echo post_permalink(get_query_var('wl_view')); ?> " data-send="true" data-action="like" <?php echo $facebook_layout; ?> data-share="<?php echo $data_share; ?> " data-width="" data-show-faces="false"></div> </div> <?php } ?> <?php if (edd_wl_sharing_is_enabled('googleplus')) { $google_button_annotation = apply_filters('edd_wl_googleplus_button_annotation', 'bubble'); $google_button_recommendations = apply_filters('edd_wl_googleplus_button_recommendations', 'false'); ?> <div class="edd-wl-service googleplus"> <div class="g-plusone" data-recommendations="<?php echo $google_button_recommendations; ?> " data-annotation="<?php echo $google_button_annotation; ?> " data-callback="plusOned" <?php echo $googleplus_layout; ?> data-href="<?php echo $share_url; ?> "></div> </div> <?php } ?> <?php if (edd_wl_sharing_is_enabled('linkedin')) { $locale = apply_filters('edd_wl_linkedin_locale', 'en_US'); ?> <div class="edd-wl-service linkedin"> <script src="//platform.linkedin.com/in.js" type="text/javascript">lang: <?php echo $locale; ?> </script> <script type="IN/Share" <?php echo $linkedin_layout; ?> data-onSuccess="share" data-url="<?php echo $share_url; ?> "></script> </div> <?php } ?> <?php do_action('edd_wl_after_share_box'); ?> </div> <?php $share_box = ob_get_clean(); return apply_filters('edd_wl_share_box', $share_box); }
<?php /** * Template part for displaying single posts. * * @link https://codex.wordpress.org/Template_Hierarchy * * @package _s */ $byline = sprintf(esc_html_x('%s', 'post author', '_s'), '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>'); $day = get_the_date('l'); $month = get_the_date('F'); $date = get_the_date('j'); $year = get_the_date('Y'); $post_link = wp_get_shortlink(); ?> <article id="post-<?php the_ID(); ?> " <?php post_class(); ?> > <header class="entry-header"> <a href="<?php the_permalink(); ?> " title="<?php the_title_attribute(); ?>
<?php global $post, $page_builder_id; $share_box_class= "mini-share-post"; if( is_singular() && empty( $page_builder_id ) ) $share_box_class = "share-post"; $post_link = tie_get_option( 'share_shortlink' ) ? esc_url( wp_get_shortlink() ) : esc_url( get_permalink() ); $post_title = wp_strip_all_tags( get_the_title() ); $protocol = is_ssl() ? 'https' : 'http'; ?> <div class="<?php echo $share_box_class ?>"> <span class="share-text"><?php _eti( 'Share' );?></span> <?php if( tie_get_option( 'share_post_type' ) == 'flat' ) : $post_title = htmlspecialchars(urlencode(html_entity_decode( $post_title, ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8'); ?> <ul class="flat-social"> <?php if( tie_get_option( 'share_facebook' ) ): ?> <li><a href="http://www.facebook.com/sharer.php?u=<?php echo $post_link; ?>" class="social-facebook" rel="external" target="_blank"><i class="fa fa-facebook"></i> <span><?php _eti( 'Facebook' );?></span></a></li> <?php endif; ?> <?php if( tie_get_option( 'share_tweet' ) ): ?> <li><a href="https://twitter.com/intent/tweet?text=<?php echo $post_title; ?><?php if( tie_get_option( 'share_twitter_username' )) echo ' via %40'.tie_get_option( 'share_twitter_username' ); ?>&url=<?php echo $post_link; ?>" class="social-twitter" rel="external" target="_blank"><i class="fa fa-twitter"></i> <span><?php _eti( 'Twitter' );?></span></a></li> <?php endif; ?> <?php if( tie_get_option( 'share_google' ) ): ?> <li><a href="https://plusone.google.com/_/+1/confirm?hl=en&url=<?php echo $post_link; ?>&name=<?php echo $post_title; ?>" class="social-google-plus" rel="external" target="_blank"><i class="fa fa-google-plus"></i> <span><?php _eti( 'Google +' );?></span></a></li> <?php endif; ?> <?php if( tie_get_option( 'share_stumble' ) ): ?> <li><a href="http://www.stumbleupon.com/submit?url=<?php echo $post_link; ?>&title=<?php echo $post_title;?>" class="social-stumble" rel="external" target="_blank"><i class="fa fa-stumbleupon"></i> <span><?php _eti( 'Stumbleupon' );?></a></span></li> <?php endif; ?> <?php if( tie_get_option( 'share_linkdin' ) ): ?>