Exemple #1
0
 /**
  * Get the share_buttons configuration to be used by Shareaholic.js
  *
  * This function returns an object for the share buttons configuration
  * which will be consumed by Shareaholic.js
  *
  * @return array an associative array of configuration for share buttons
  */
 public static function get_share_buttons_config()
 {
     $share_buttons = array();
     $disable_share_counts_api = ShareaholicUtilities::get_option('disable_internal_share_counts_api');
     $share_counts_connect_check = ShareaholicUtilities::get_option('share_counts_connect_check');
     if (isset($disable_share_counts_api)) {
         if (isset($share_counts_connect_check) && $share_counts_connect_check == 'SUCCESS' && $disable_share_counts_api != 'on') {
             $share_buttons['get_share_counts'] = '%get_share_counts%';
         }
     }
     return $share_buttons;
 }
Exemple #2
0
 /**
  * Return a base set of settings for the Shareaholic JS or Publisher SDK
  */
 public static function get_base_settings()
 {
     $base_settings = array('endpoints' => array('local_recs_url' => admin_url('admin-ajax.php') . '?action=shareaholic_permalink_related'));
     $disable_share_counts_api = ShareaholicUtilities::get_option('disable_internal_share_counts_api');
     $share_counts_connect_check = ShareaholicUtilities::get_option('share_counts_connect_check');
     if (isset($disable_share_counts_api)) {
         if (isset($share_counts_connect_check) && $share_counts_connect_check == 'SUCCESS' && $disable_share_counts_api != 'on') {
             $base_settings['endpoints']['share_counts_url'] = admin_url('admin-ajax.php') . '?action=shareaholic_share_counts_api';
         }
     }
     return $base_settings;
 }
 /**
  * Get _SHR_SETTINGS config for shareaholic js
  */
 public static function get_base_settings()
 {
     $base_settings = array();
     $disable_share_counts_api = ShareaholicUtilities::get_option('disable_internal_share_counts_api');
     $share_counts_connect_check = ShareaholicUtilities::get_option('share_counts_connect_check');
     if (isset($disable_share_counts_api)) {
         if (isset($share_counts_connect_check) && $share_counts_connect_check == 'SUCCESS' && $disable_share_counts_api != 'on') {
             $base_settings['endpoints'] = array('share_counts_url' => url('shareaholic/api/share_counts/v1', array('absolute' => TRUE)));
         }
     }
     return $base_settings;
 }
/**
 * The form object for the advanced settings
 *
 */
function shareaholic_advanced_settings_form()
{
    $disable_og_tags_checked = ShareaholicUtilities::get_option('disable_og_tags');
    $disable_internal_share_counts_api_checked = ShareaholicUtilities::get_option('disable_internal_share_counts_api');
    $form['advanced_settings'] = array('#prefix' => '<fieldset class="app"><legend><h2>' . t('Advanced') . '</h2></legend>', '#suffix' => '</fieldset>');
    $form['advanced_settings']['disable_og_tags'] = array('#type' => 'checkbox', '#title' => t('Disable ') . '<code>' . t('Open Graph') . '</code>' . t(' tags (it is recommended NOT to disable open graph tags)'));
    $form['advanced_settings']['disable_internal_share_counts_api'] = array('#type' => 'checkbox', '#title' => t('Disable server-side Share Counts API (unless there are issues with calling the service, it is recommended NOT to disable this API)'));
    $form['advanced_settings']['submit'] = array('#type' => 'submit', '#value' => t('Save Changes'));
    $form['advanced_settings']['submit']['#attributes']['class'][] = 'settings';
    $form['advanced_settings']['submit']['#attributes']['onclick'][] = 'this.value="Saving Settings..."';
    if ($disable_og_tags_checked === 'on') {
        $form['advanced_settings']['disable_og_tags']['#attributes'] = array('checked' => 'checked');
    }
    if ($disable_internal_share_counts_api_checked === 'on') {
        $form['advanced_settings']['disable_internal_share_counts_api']['#attributes'] = array('checked' => 'checked');
    }
    return $form;
}
Exemple #5
0
 /**
  * Handles publishing or updating a post
  *
  * @param  string $post_id the post id
  * @return bool   whether the request worked
  */
 public static function post_notify($post_id)
 {
     global $wpdb;
     $post = get_post($post_id);
     $url = get_permalink($post_id);
     $tags = wp_get_post_tags($post_id, array('fields' => 'names'));
     $categories = array_map(array('ShareaholicNotifier', 'post_notify_iterator'), get_the_category($post_id));
     if (function_exists('has_post_thumbnail') && has_post_thumbnail($post_id)) {
         $featured_image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'large');
     } else {
         $featured_image = ShareaholicUtilities::post_first_image();
         if (!$featured_image) {
             $featured_image = '';
         }
     }
     if ($post->post_author) {
         $author_data = get_userdata($post->post_author);
         $author_name = $author_data->display_name;
     }
     $notification = array('url' => $url, 'api_key' => ShareaholicUtilities::get_option('api_key'), 'content' => array('title' => $post->post_title, 'excerpt' => $post->post_excerpt, 'body' => $post->post_content, 'featured-image-url' => $featured_image), 'metadata' => array('author-id' => $post->post_author, 'author-name' => $author_name, 'post-type' => $post->post_type, 'post-id' => $post_id, 'post-tags' => $tags, 'post-categories' => $categories, 'post-language' => get_bloginfo('language'), 'published' => $post->post_date_gmt, 'updated' => get_lastpostmodified('GMT'), 'visibility' => $post->post_status), 'diagnostics' => array('platform' => 'wordpress', 'platform-version' => get_bloginfo('version'), 'shareaholic-version' => Shareaholic::VERSION, 'wp-multisite' => is_multisite(), 'wp-theme' => get_option('template'), 'wp-posts-total' => $wpdb->get_var("SELECT count(ID) FROM {$wpdb->posts} where post_type = 'post' AND post_status = 'publish'"), 'wp-pages-total' => $wpdb->get_var("SELECT count(ID) FROM {$wpdb->posts} where post_type = 'page' AND post_status = 'publish'"), 'wp-comments-total' => wp_count_comments()->approved, 'wp-users-total' => $wpdb->get_var("SELECT count(ID) FROM {$wpdb->users}")));
     return self::send_notification($notification);
 }
<div class='reveal-modal' id='editing_modal'>
  <div id='iframe_container' class='bg-loading-img' allowtransparency='true'></div>
  <a class="close-reveal-modal">&#215;</a>
</div>

<script>
window.first_part_of_url = "<?php 
echo ShareaholicUtilities::URL . '/publisher_tools/' . ShareaholicUtilities::get_option('api_key');
?>
/";
window.verification_key = "<?php 
echo ShareaholicUtilities::get_option('verification_key');
?>
";
window.shareaholic_api_key = "<?php 
echo ShareaholicUtilities::get_option('api_key');
?>
";
</script>

<div class='unit size3of5'>
<?php 
$form = drupal_get_form('shareaholic_apps_configuration_form');
print drupal_render($form);
?>
</div>

  <div class="signuppromo unit size1of5">
  <p class="promoh1"><?php 
print t('Gain access to more features with a FREE Shareaholic account:');
?>
Exemple #7
0
 /**
  * Sends an event when the user has updated
  * the Drupal module
  */
 public static function update_check()
 {
     $version = ShareaholicUtilities::get_option('version');
     if (ShareaholicUtilities::get_option('api_key') && $version != ShareaholicUtilities::get_version()) {
         ShareaholicUtilities::set_version(ShareaholicUtilities::get_version());
         ShareaholicUtilities::log_event('Upgrade', array('previous_plugin_version' => $version));
     }
 }
Exemple #8
0
 /**
  * Function to return related permalinks for a given permalink to bootstrap the Related Content app until the off-line processing routines complete
  *
  * @return list of related permalinks in JSON
  */
 public static function permalink_related()
 {
     global $post;
     // Input Params
     $permalink = isset($_GET['permalink']) ? $_GET['permalink'] : NULL;
     $match = isset($_GET['match']) ? $_GET['match'] : "random";
     // match method
     $n = isset($_GET['n']) ? intval($_GET['n']) : 10;
     // number of related permalinks to return
     $related_permalink_list = array();
     // Get post ID
     if ($permalink == NULL) {
         // default to random match if no permalink is available
         $match = "random";
     } else {
         $post_id = url_to_postid($permalink);
         // for non-default paths - handle both https and http versions of the permalink
         if ($post_id == 0) {
             $parse = parse_url($permalink);
             if ($parse['scheme'] == "https") {
                 $permalink = str_replace("https", "http", $permalink);
                 $post_id = url_to_postid($permalink);
             } else {
                 if ($parse['scheme'] == "http") {
                     $permalink = str_replace("http", "https", $permalink);
                     $post_id = url_to_postid($permalink);
                 }
             }
         }
     }
     if ($match == "random") {
         $args = array('posts_per_page' => $n, 'orderby' => 'rand');
         $rand_posts = get_posts($args);
         foreach ($rand_posts as $post) {
             $related_link = array('page_id' => $post->ID, 'url' => get_permalink($post->ID), 'title' => $post->post_title, 'description' => $post->post_excerpt, 'image_url' => ShareaholicUtilities::permalink_thumbnail($post->ID, "medium"), 'score' => 1);
             array_push($related_permalink_list, $related_link);
         }
         wp_reset_postdata();
     } else {
         // other methods coming soon
     }
     // Construct results array
     $result = array('request' => array('api_key' => ShareaholicUtilities::get_option('api_key'), 'url' => $permalink), 'internal' => $related_permalink_list);
     header('Content-Type: application/json; charset=utf-8');
     header('Cache-Control: max-age=180');
     // 3 minutes
     echo json_encode($result);
     exit;
 }
Exemple #9
0
 /**
  * Insert the Open Graph Tags
  */
 public static function insert_og_tags($node = false, $view_mode = '')
 {
     $markup = '';
     $disable_og_tags_check = ShareaholicUtilities::get_option('disable_og_tags');
     if ($disable_og_tags_check && $disable_og_tags_check == 'on') {
         return;
     }
     if ($view_mode != 'full') {
         return;
     }
     if ($node && (!isset($node->shareaholic_options["shareaholic_exclude_og_tags"]) || !$node->shareaholic_options["shareaholic_exclude_og_tags"])) {
         $image_url = self::get_image_url_for($node);
         if (!empty($image_url)) {
             $markup .= "\n<!-- Shareaholic Open Graph Tags -->\n";
             $markup .= "<meta property='og:image' content='" . $image_url . "' />";
             $markup .= "\n<!-- Shareaholic Open Graph Tags End -->\n";
         }
     }
     $element = array('#type' => 'markup', '#markup' => $markup);
     drupal_add_html_head($element, 'shareaholic_og_tags');
 }
 /**
  * This function fires after the plugin has been activated.
  */
 public function after_activation()
 {
     $this->terms_of_service();
     ShareaholicUtilities::log_event("Activate");
     // workaround: http://codex.wordpress.org/Function_Reference/register_activation_hook
     add_option('Activated_Plugin_Shareaholic', 'shareaholic');
     if (ShareaholicUtilities::has_accepted_terms_of_service() && ShareaholicUtilities::get_option('api_key') != NULL) {
         ShareaholicUtilities::notify_content_manager_sitemap();
         ShareaholicUtilities::notify_content_manager_singledomain();
     }
     if (!ShareaholicUtilities::get_version()) {
         ShareaholicUtilities::log_event("Install_Fresh");
     }
     // Activate the Shareaholic Cron Job for new users
     ShareaholicCron::activate();
 }
Exemple #11
0
 /**
  * This function is in charge of sending the "get started" email
  */
 public static function send_welcome_email()
 {
     $site_url = get_bloginfo('url');
     $api_key = ShareaholicUtilities::get_option('api_key');
     $payment_url = 'https://shareaholic.com/account';
     $shr_wp_dashboard_url = admin_url('admin.php?page=shareaholic-settings');
     $sign_up_link = 'https://shareaholic.com/publisher_tools/' . ShareaholicUtilities::get_option('api_key') . '/verify?verification_key=' . ShareaholicUtilities::get_option('verification_key') . '&redirect_to=' . 'https://shareaholic.com/publisher_tools/' . ShareaholicUtilities::get_option('api_key') . '/websites/edit?verification_key=' . ShareaholicUtilities::get_option('verification_key');
     $to = get_bloginfo('admin_email');
     $subject = 'Thank you for installing Shareaholic for WordPress!';
     $message = "\n    <p>Hi there,</p>\n    \n    <p>Thank you for installing Shareaholic on {$site_url}! You are one step closer to growing your website traffic and revenue with our award winning  all-in-one content amplification platform. Completing your set-up is easy, just follow these three easy steps and you'll be ready to go:</p>\n        \n    <p><strong>Step 1. Customize to your needs</strong><br /><br />\n    \n    Personalize the design of the Share Buttons and Related Content Recommendations App to match your website using the \"Customize\" buttons in your <a href='{$shr_wp_dashboard_url}'>Shareaholic App Manager in WordPress</a>, then choose where you want them to appear on your website using the checkboxes!\n            \n    <p><strong>Step 2: Sign-up for a free Shareaholic account</strong><br /><br />\n    \n    This will allow you to add more (free!) features like Analytics, Floating Share Buttons, Follow Buttons and more. <strong><a href='{$sign_up_link}'>Click here to sign-up</a></strong>, or <a href='{$sign_up_link}'>login to an existing Shareaholic account</a> and we'll automatically sync the plugin settings with your account.</p>\n    \n    <p><strong>Step 3: Control your earnings and setup how you would like to get paid</strong><br /><br />\n    \n    Decide how much you would like to earn from Promoted Content (native ads that appear in the Related Content app) and other monetization apps by editing your settings in the \"Monetization\" section of the plugin. Next, visit the \"Username and email address\" <a href='{$payment_url}'>section of your Shareaholic.com account</a> to add your PayPal information, so you can collect the revenue you generate from Shareaholic.</p>\n    \n    <p>Have questions? Simply reply to this email and we will help you out!</p>\n\n    <p>Let's get started,<br /><br />\n    \n    Mary Anne & Cameron<br />\n    Shareaholic Happiness Team<br />\n    <a href='http://support.shareaholic.com'>support.shareaholic.com</a><br /><br />\n    <img width='200' height='36' src='https://shareaholic.com/assets/layouts/shareaholic-logo.png' alt='Shareaholic' title='Shareaholic' /><br />\n    <p style='font-size:12px;color:#C3C2C2;'>This is an automated, one-time e-mail sent by your WordPress CMS directly to the website admin</p><br />\n    <img width='0' height='0' src='https://www.google-analytics.com/collect?v=1&tid=UA-12964573-6&cid={$api_key}&t=event&ec=email&ea=open&el={$site_url}-{$api_key}&cs=lifecycle&cm=email&cn=wp_welcome_email' />";
     $headers = "From: Shareaholic <*****@*****.**>\r\n";
     $headers .= "Reply-To: Mary Anne <*****@*****.**>\r\n";
     $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";
     $headers .= "MIME-Version: 1.0\r\n";
     $headers .= "Content-type: text/html; charset=utf-8\r\n";
     if (function_exists('wp_mail')) {
         wp_mail($to, $subject, $message, $headers);
     }
 }
Exemple #12
0
 /**
  * Check if the installation has accepted ToS and we created an apikey
  *
  */
 public static function has_tos_and_apikey()
 {
     return ShareaholicUtilities::has_accepted_terms_of_service() && ShareaholicUtilities::get_option('api_key');
 }
</div>
      <?php 
}
?>
    </fieldset>
    
    <div class='clear'></div>
    
    <fieldset class="app">
      <legend><h2><?php 
_e('Your Shareaholic Site ID', 'shareaholic');
?>
</h2></legend>
      <?php 
if (ShareaholicUtilities::get_option('api_key')) {
    echo '<code>' . ShareaholicUtilities::get_option('api_key') . '</code>';
} else {
    _e('Not set.', 'shareaholic');
}
?>
    </fieldset>
    
    <div class='clear'></div>
    
    <form name='reset_settings' method='post' action='<?php 
echo $action;
?>
'>
      <?php 
wp_nonce_field($action, 'nonce_field');
?>