This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Plugin Name: ID24 Social Sharing | |
* Plugin URI: | |
* Plugin Description: Demo plug-in for #ID24 and #GAAD | |
* Version: 1.0 | |
* Author: Joe Dolson | |
* Author URI: http://www.joedolson.com | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Get the post data that will be sent to social sharing pages. | |
* | |
* @param integer $post_ID ID of the current post. | |
* | |
* @return array of post data. | |
*/ | |
function id24_post_information( $post_ID ) { | |
$data = array(); | |
$data['title'] = get_the_title( $post_ID ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Generate the URLs used to post data to services. | |
* | |
* @param integer $post_ID of current post | |
* | |
* @return array of URLs for posting to each service. | |
*/ | |
function id24_create_urls( $post_ID ) { | |
$data = id24_post_information( $post_ID ); | |
$twitter = "https://twitter.com/intent/tweet?text=" . urlencode( $data['title'] . ' ' . $data['url'] ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Generate the HTML links using URLs. | |
* | |
* @param integer $post_ID of current post | |
* | |
* @return string block of HTML links. | |
*/ | |
function id24_create_links( $post_ID ) { | |
$urls = id24_create_urls( $post_ID ); | |
$html = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Fetch HTML for links and wrap in a container. Add heading and ARIA landmark role. | |
* | |
* @param integer $post_ID of current post. | |
* | |
* @return full HTML block. | |
*/ | |
function id24_social_block( $post_ID ) { | |
$links = id24_create_links( $post_ID ); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Use WordPress filter 'the_content' to add sharing links into post content. | |
* | |
* @param $content The current content of the post. | |
* | |
* @return $content The previous content of the post plus social sharing links. | |
*/ | |
add_filter( 'the_content', 'id24_post_content' ); | |
function id24_post_content( $content ) { | |
global $post; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Register custom stylesheet for ID24 social sharing. | |
*/ | |
add_action( 'wp_enqueue_scripts', 'id24_register_styles' ); | |
function id24_register_styles() { | |
wp_register_style( 'id24-icomoon', plugins_url( 'fonts/icomoon.css', __FILE__ ) ); | |
if ( !is_admin() ) { | |
wp_enqueue_style( 'id24-social-share', plugins_url( 'css/id24.css', __FILE__ ), array( 'dashicons', 'id24-icomoon' ) ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Generate the HTML links using URLs. | |
* | |
* @param integer $post_ID of current post | |
* | |
* @return string block of HTML links. | |
*/ | |
function id24_create_links( $post_ID ) { | |
$urls = id24_create_urls( $post_ID ); | |
$html = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'mc_save_event', 'my_event_post', 10, 3 ); | |
function my_event_post( $action, $data, $new_event ) { | |
// if the event save was successful. | |
if ( $action == 'add' ) { | |
$title = $data['event_title']; | |
$content = "[my_calendar_event event='$new_event' template='details' list='']"; | |
$post_status = 'publish'; | |
$auth = $data['event_author']; | |
$type = 'post'; | |
$my_post = array( |
OlderNewer