Plugin Directory

Changeset 597682


Ignore:
Timestamp:
09/11/2012 07:27:44 PM (13 years ago)
Author:
rsingel
Message:

Core javascript now called via HTTPS, Jquery check now uses WP built-in method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • contextly-related-links/trunk/contextly-linker.php

    r580150 r597682  
    11<?php
    2 /**
    3  * @package Contextly_Linker
    4  * @version 1.0.65
    5  */
     2
    63/*
    74Plugin Name: Contextly Linker
     
    96Description: Adds the Contextly related links tool to your blog. Contextly lets you create related links that helps your readers find more to read, increases your page views and shows off your best content.
    107Author: Contextly
    11 Version: 1.0.65
     8Version: 1.0.70
    129*/
    1310
     11define( "CONTEXTLY_PLUGIN_VERSION", "1.0.70" );
     12define( "CONTEXTLY_MAIN_SERVER_URL", "https://contextly.com/" );
     13
    1414function contextly_get_plugin_url() {
    15     return "http://contextlysiteimages.contextly.com/_plugin/1.0.65/js/linker-plugin.js";
     15    return "https://c713421.ssl.cf2.rackcdn.com/_plugin/" . CONTEXTLY_PLUGIN_VERSION . "/js/linker-plugin.js";
    1616}
    1717
     
    5555
    5656function contextly_addbuttons() {
    57     wp_enqueue_script('jquery');
    58 
    5957    // Don't bother doing this stuff if the current user lacks permissions
    6058    if (! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) return;
     
    104102if (!class_exists("ContextlyActivate")) {
    105103    class ContextlyActivate {
    106         var $server_url= "https://contextly.com/";
     104        var $server_url= CONTEXTLY_MAIN_SERVER_URL;
    107105        var $general_settings_key = 'contextly_options_general';
    108106        var $advanced_settings_key = 'contextly_options_advanced';
     
    201199            <script type="text/javascript">
    202200                function open_contextly_settings() {
    203                     window.open("<?php echo $this->server_url ?>redirect.php?type=settings&blog_url=<?php echo site_url(); ?>");
     201                    window.open("<?php echo $this->server_url ?>redirect/?type=settings&blog_url=<?php echo site_url(); ?>");
    204202                }
    205203            </script>
     
    244242            $post_data["post_date"] = $post->post_date;
    245243            $post_data["post_status"] = $post->post_status;
     244            $post_data["post_type"] = $post->post_type;
    246245            return $post_data;
    247246        }
     
    265264            return $advanced_option;
    266265        }
     266       
     267        function getAuthorInfo( $post ) {
     268            return array(
     269                        "id" => $post->post_author,
     270                        "firstname" => get_the_author_meta( "first_name", $post->post_author ),
     271                        "lastname" => get_the_author_meta( "last_name", $post->post_author ),
     272                        "display_name" => get_the_author_meta( "display_name", $post->post_author )
     273                    );
     274        }
    267275
    268276        // Add main js stuff for contextly api calls
    269277        function buildJsData($admin_mode = false) {
    270278            global $post;
    271             ?>
     279
     280            ?>
    272281            <script data-cfasync="false" type="text/javascript">
    273282                var contextly_post_object = {
     
    277286                        blog_title: "<?php echo get_bloginfo("name"); ?>",
    278287                        page_permalink: "<?php echo get_permalink($post->ID); ?>",
    279                         author: <?php echo json_encode(array("id" => $post->post_author, "firstname" => get_the_author_meta("first_name", $post->post_author), "lastname" => get_the_author_meta("last_name", $post->post_author))) ?>,
     288                        author: <?php echo json_encode( $this->getAuthorInfo( $post ) ) ?>,
    280289                        admin: <?php echo (int)$admin_mode; ?>,
    281                         version: '1.0.65'
     290                        version: "<?php echo CONTEXTLY_PLUGIN_VERSION ?>"
    282291                };
    283292
    284293                var contextly_settings = <?php echo json_encode($this->get_options()); ?>;
    285 
    286                 (function() {
    287                     var src = document.createElement('script');
    288                     src.async = true;
    289                     src.src = "<?php echo contextly_get_plugin_url(); ?>";
    290                     if (contextly_post_object.admin) {
    291                         if (src.readyState) { // IE
    292                         } else { //Others
    293                             src.onerror = function () {
    294                                 jQuery("#linker_widget").html("Error loading data from <a target='_blank' href='http://contextly.com'>contextly.com</a>. Please <a target='_blank' href='http://contextly.com'>contact us</a> so we can help resolve the problem.");
    295                             };
    296                         }
    297                     }
    298                     document.getElementsByTagName('head')[0].appendChild(src);
    299                 }());
    300294            </script>
    301295            <?php
    302         }
     296
     297            wp_enqueue_script( 'jquery' );
     298            wp_enqueue_script( 'contextly', contextly_get_plugin_url(), 'jquery', CONTEXTLY_PLUGIN_VERSION, false );
     299        }
    303300
    304301        // Admin header
     
    308305            // Check if this is admin edit page action
    309306            if ($pagenow == "post.php" || $pagenow == "post-new.php") {
    310                 ?>
    311                 <script type="text/javascript" src="//contextlysitescripts.contextly.com/js/easyXDM.min.js"></script>
    312                 <script type="text/javascript" src="//contextlysitescripts.contextly.com/js/jquery.xdomainajax.js"></script>
     307                ?>
     308                <script type="text/javascript" src="https://c714015.ssl.cf2.rackcdn.com/js/easyXDM.min.js"></script>
     309                <script type="text/javascript" src="https://c714015.ssl.cf2.rackcdn.com/js/jquery.xdomainajax.js"></script>
    313310                <?php echo $this->buildJsData(true); ?>
    314311                <?php
     
    319316        function head() {
    320317            if (is_single()) {
    321                 $this->buildJsData();
     318                $this->buildJsData();
    322319            }
    323320        }
     
    395392    add_action('admin_init', 'contextly_add_see_also_meta_box', 1);
    396393}
    397 ?>
Note: See TracChangeset for help on using the changeset viewer.