Plugin Directory

Changeset 803512


Ignore:
Timestamp:
11/13/2013 02:57:33 AM (11 years ago)
Author:
noticesoftware
Message:

Updates to functions - add Roost JS to footer - Safari Web Push

Location:
roost-for-bloggers/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • roost-for-bloggers/trunk/readme.txt

    r797862 r803512  
    11=== Roost For Bloggers ===
    22Contributors: noticesoftware
    3 Tags: notifications, push notifications, alerts, website notifications, web alerts, roost, alert rocket, web push, mobile website push notification
     3Tags: notifications, push notifications, alerts, website notifications, web alerts, roost, alert rocket, web push, mobile website push notification, safari web push, desktop push notification, OS X Mavericks, web push, desktop push
    44Requires at least: 3.0
    55Tested up to: 3.7
    6 Stable tag: 1.0
     6Stable tag: 1.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1212== Description ==
    1313
    14 [Roost](http://roost.me/) For Bloggers Wordpress plugin provides direct engagement with your readers by sending push notifications to their mobile devices when you create a new post. Notifications are sent with links, pushing readers back to your site.
     14[Roost](http://roost.me/) For Bloggers Wordpress plugin provides direct engagement with your readers by sending push notifications to their mobile device, or web browser, when you create a new post. Notifications are sent with links, pushing readers back to your site.
    1515
    1616Your readers will be able to subscribe to receive notification using either one of the pre-built registration options, or a custom one that you define.
     
    1818Roost For Bloggers Wordpress Plugin Features:
    1919
     20* *NEW* Safari Web Push (Desktop Push Notifications) on OS X Mavericks
    2021* Free Roost For Bloggers account
    2122* Auto notifications when creating a new post
     
    2526* Roost social button and mobile button for registration
    2627* Easy registration from both mobile devices and desktop browsers
     28* Detailed analytics provided through the Roost dashboard
    2729
    2830== Installation ==
     
    4345
    4446**Auto Push**
    45 
    4647Auto Push is what makes this plugin stellar. When you create a new post, your post's title and link will be sent to all of your subscribed readers. That's it. Really. You don't have to do anything else. (It works just like magic.)
    4748
     49**Safari Web Push**
     50To use Safari Web Push, simply activate the *Roost for Bloggers* plugin. When your site is viewed in a push-enabled browser and a Roost button or bar is clicked, the browser will prompt for permission. No additional setup is needed.
     51
    4852**Use Custom Text**
    49 
    5053When enabled, the text you enter here will be attached to the auto-pushed messages. You can choose to place this text before or after the auto message.
    5154
    5255**Send Manual Alert**
    53 
    5456You can send a manual alert to all subscribed users by entering your message text in the "Message" box and a link in the "Link" box.
    5557
    5658**Roost Buttons**
    57 
    5859Two button types are provided, a social-style button and a mobile-style button. These need to be manually put into your theme templates or used on individual posts. We tried to make it as easy as possible...
    5960
    6061To use the Roost social button, simply place this shortcode into your content:
    61 '[Roost]'
     62[Roost]
    6263
    6364The mobile style button is generated by using this shortcode:
    64 '[RoostMobile]'
     65[RoostMobile]
     66
     67**Roost Analytics & Roost JS**
     68Detailed metrics are provided in the Roost dashboard about your subscribers. These metrics include reads, pages view, messages received, and time on site.
    6569
    6670**Notes**
    67 
    68 To use any of the integrated registration options below, you will need to be using a Wordpress template that generates the *Content* section on pages. If you use a *static* page, such as a custom homepage, you will need to manually insert the blank containers and Roost JavaScript on those pages.
     71To use any of the integrated registration options below, you will need to be using a Wordpress template that generates the *Content* section on pages. If you use a *static* page, such as a custom homepage, you will need to manually insert the empty containers. The Roost JS is inserted into the footer via the *wp_footer()* function. If your theme does not use this function, you will need to manually copy / paste the Roost JS code snippet.
    6972
    7073**Roost Header / Footer Bar**
    71 
    7274To enable the Roost Header / Footer bar, select it from the dropdown in the registration section of the Roost dashboard. A *Custom Text* box will appear. Here you are able to customize the text that is displayed on the bar.
    7375
    7476**Custom Registration**
    75 
    7677If you would like to handle your own registration code, choose this method. Anything you put in this box will be inserted into the *Content* section of each page.
    7778
     
    103104
    104105= 1.0 =
    105 *Initial Release
     106* Initial Release
     107
     108= 1.1 =
     109* Added support for Safari Web Push (Desktop Push Notifications) on OS X Mavericks
     110* Prefixed functions to avoid conflicts
     111* Updated settings to be removed on uninstall instead of deactivation
     112* Included Roost JS on every page via wp_footer() - (Needed for Roost analytics such as page views and time on site)
  • roost-for-bloggers/trunk/roost.php

    r797566 r803512  
    44Plugin URI: http://www.roost.me/
    55Description: Wordpress plugin for Roost.me Web-Push. Automate Push Notifications with new posts or send manually from the dashboard.
    6 Version: 1.0
     6Version: 1.1
    77Author: Roost.me
    88Author URI: http://www.roost.me/
     
    3333    add_action('publish_post', 'roostme');
    3434    register_activation_hook(__FILE__, 'roost_install');
    35     register_deactivation_hook(__FILE__, 'roost_uninstall');
     35    register_uninstall_hook(__FILE__, 'roost_uninstall');
    3636   
    3737    function roost_install(){
     
    5959            VALUES('', '', 1, 0, '', '', '0', '', '', '' )");
    6060        }
    61         register_sidebar(array(
    62             'name' => 'Roost Top',
    63             'id' => 'roost-top',
    64             'before_widget' => '<li>',
    65             'after_widget' => "</li>",
    66             'before_title' => "<h3>",
    67             'after_title' => "</h3>"
    68         ));
    6961    }
    7062   
     
    8072            "Roost.me",
    8173            "Roost.me",
    82             8,
     74            "manage_options",
    8375            __FILE__,
    8476            "roost_admin_menu_list",
     
    9587    add_action('admin_menu', 'roost_admin_menu');
    9688   
    97     function remoteRequest($remoteData) {
     89    function roost_remoteRequest($remoteData) {
    9890        $authCreds = '';
    9991        if(!empty($remoteData['appkey'])) {
     
    129121            'remoteContent' => json_encode($remoteContent)
    130122        );
    131         return remoteRequest($remoteData);     
    132     }
    133    
    134     function saveUsername($roostUser){
     123        return roost_remoteRequest($remoteData);       
     124    }
     125   
     126    function roost_saveUsername($roostUser){
    135127        global $wpdb;
    136128        $table = $wpdb->prefix . "roostsettings";
     
    139131    }
    140132   
    141     function updateKeys($formKeys){
     133    function roost_updateKeys($formKeys){
    142134        global $wpdb;
    143135        $table = $wpdb->prefix . "roostsettings";
     
    148140    }
    149141   
    150     function updateSettings($formData){
     142    function roost_updateSettings($formData){   
    151143        global $wpdb;
    152144        $table = $wpdb->prefix . "roostsettings";
     
    201193                $customhtml = $custommsg;
    202194            }
    203             $content = $customhtml . $content . roostJS($appkey);
     195            $content = $customhtml . $content;
    204196        }
    205197        if(!is_page() && !is_single()){
     
    249241                }
    250242                $url = $siteurl . "/?p=" . $post_ID;
    251                 sendNotification($alert, $url, $appkey, $appsecret);
     243                roost_sendNotification($alert, $url, $appkey, $appsecret);
    252244            }       
    253245        }
    254246    }
    255247   
    256     function buildMsg($manualtext, $manuallink) {
     248    function roost_buildMsg($manualtext, $manuallink) {
    257249        global $wpdb;
    258250        $table = $wpdb->prefix . "roostsettings";
     
    267259            }
    268260        }
    269         sendNotification($manualtext, $manuallink, $appkey, $appsecret);
    270     }
    271    
    272     function sendNotification($alert, $url, $appkey, $appsecret) {
     261        roost_sendNotification($manualtext, $manuallink, $appkey, $appsecret);
     262    }
     263   
     264    function roost_sendNotification($alert, $url, $appkey, $appsecret) {
    273265        if(!$url){
    274266            $remoteContent = array(
     
    287279            'remoteContent' => json_encode($remoteContent)
    288280        );
    289         remoteRequest($remoteData);
    290     }
    291    
    292     function roostJS($appkey) {
    293         $roostJS = "<script>";
    294         $roostJS = $roostJS . "var _roost = _roost || [];";
    295         $roostJS = $roostJS . "_roost.push(['appkey','". $appkey ."']);";
    296         $roostJS = $roostJS . "!function(d,s,id){";
    297         $roostJS = $roostJS . "var js, fjs = d.getElementsByTagName(s)[0];";
    298         $roostJS = $roostJS . "if(!d.getElementById(id)){";
    299         $roostJS = $roostJS . "js=d.createElement(s); js.id=id;";
    300         $roostJS = $roostJS . "js.src='//get.roost.me/js/roost.js';";
    301         $roostJS = $roostJS . "fjs.parentNode.insertBefore(js,fjs);";
    302         $roostJS = $roostJS . "}";
    303         $roostJS = $roostJS . "}(document, 'script', 'roost-js');";
    304         $roostJS = $roostJS . "</script>";
    305         return $roostJS;
     281        roost_remoteRequest($remoteData);
    306282    }
    307283   
     
    319295            $roostButton = "<div class='roost-button' data-segments='" . $segments . "'></div>";
    320296        }
    321         return $roostButton . roostJS($appkey);
     297        return $roostButton;
    322298    }
    323299    add_shortcode('Roost', 'roostbtn');
     
    336312            $roostButton = "<div class='roost-button-mobile' data-segments='" . $segments . "'></div>";
    337313        }
    338         return $roostButton . roostJS($appkey);
     314        return $roostButton;
    339315    }
    340316    add_shortcode('RoostMobile', 'roostmbtn');
     
    346322            $logginIntoRoost = json_decode(wp_remote_retrieve_body(roostLogin($roostUser, $roostPass)), true);
    347323            if($logginIntoRoost['success'] === true) {
    348                 saveUsername($roostUser);
     324                roost_saveUsername($roostUser);
    349325                if(count($logginIntoRoost['apps']) > 1){
    350326                    //Work in the handling for multiple configs
     
    355331                        "Appsecret" => $logginIntoRoost['apps'][0]['secret']
    356332                    );
    357                     updateKeys($formKeys);             
     333                    roost_updateKeys($formKeys);               
    358334                    $status = 'Logged in to Roost. You\'re Good to Go!';
    359335                }
     
    372348                "Appsecret" => $roostSiteSecret
    373349            );
    374             updateKeys($formKeys);
     350            roost_updateKeys($formKeys);
    375351            $status = 'Logged in to Roost. You\'re Good to Go!';
    376352        }
     
    382358            );
    383359            $roostUser = '';
    384             updateKeys($formKeys);
    385             saveUsername($roostUser);
     360            roost_updateKeys($formKeys);
     361            roost_saveUsername($roostUser);
    386362            $status = 'Roost has been disconnected.';
    387363        }
     
    397373                "customtext" => mysql_real_escape_string($_POST['customtext'])
    398374            );
    399             updateSettings($formData);
     375            roost_updateSettings($formData);
    400376            $status = 'Settings Saved.';
    401377        }
     
    409385                $status = 'Please Enter a Valid URL. - (Must contain "http://" and your ".com" or respective domain.';
    410386            } else {
    411                 buildMsg($manualtext, $manuallink);
     387                roost_buildMsg($manualtext, $manuallink);
    412388                $status = 'Message Sent.'; 
    413389            }
     
    419395                $status = 'Your Message Can Not Be Blank.';
    420396            } else {
    421                 buildMsg($manualtext, "");       
     397                roost_buildMsg($manualtext, "");       
    422398                $status = 'Message Sent.';
    423399            }
    424400        }
    425         require_once('layout/admin.php');
    426     }
     401        require_once('layout/admin.php');       
     402    }
     403               
     404    function roost_load_scripts() {
     405        global $wpdb;
     406        $table = $wpdb->prefix . "roostsettings";
     407        $sql = "SELECT * FROM " . $table . " where 1";
     408        $results = $wpdb->get_results($sql);
     409        if (count($results) > 0) {
     410            foreach ($results as $result) {
     411                $appkey = $result->appkey;
     412            }
     413        }
     414        if($appkey && !is_admin()) {
     415            wp_enqueue_script( 'roostjs', ROOST_URL . 'layout/js/roostjs.js', array('jquery'), false, true );
     416            wp_localize_script( 'roostjs', 'roostjsParams', array( 'appkey' => $appkey) );
     417        }
     418    }
     419    add_action('wp_enqueue_scripts', 'roost_load_scripts');
     420   
    427421?>
Note: See TracChangeset for help on using the changeset viewer.