WordPress.org

Plugin Directory

Changeset 573501


Ignore:
Timestamp:
07/17/12 11:42:14 (21 months ago)
Author:
dimadin
Message:

Add one-click subscription straight from the forums page. Props Davide Vecchini for idea.

Location:
bbpress-digest/trunk
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • bbpress-digest/trunk/bbpress-digest.php

    r512544 r573501  
    1212/** 
    1313 * Plugin Name: bbPress Digest 
    14  * Plugin URI: http://blog.milandinic.com/wordpress/plugins/bbpress-digest/ 
     14 * Plugin URI:  http://blog.milandinic.com/wordpress/plugins/bbpress-digest/ 
    1515 * Description: Send daily digest with forum's active topics. 
    1616 * Author:      Milan Dinić 
    1717 * Author URI:  http://blog.milandinic.com/ 
    18  * Version:     1.0 
     18 * Version:     2.0-alfa-1 
    1919 * Text Domain: bbp-digest 
    2020 * Domain Path: /languages/ 
    21  * License: GPL 
     21 * License:     GPL 
    2222 */ 
    2323 
     
    6464} 
    6565register_uninstall_hook( __FILE__, 'bbp_digest_uninstall' ); 
     66 
     67/** 
     68 * Register actions on init hook 
     69 * 
     70 * @since 2.0 
     71 */ 
     72function bbp_digest_init() { 
     73    /* Show one-click subscription */ 
     74    if ( bbp_is_single_forum() || is_user_logged_in() ) { 
     75        add_action( 'bbp_head', 'bbp_digest_head_scripts' ); 
     76        add_action( 'bbp_template_after_topics_loop', 'bbp_digest_one_click_subscription' ); 
     77    } 
     78 
     79    /* Handle one-click subscription */ 
     80    add_action( 'wp_ajax_dim-bbp-digest-subscription', 'bbp_digest_one_click_ajax_handle' ); 
     81} 
     82add_action( 'init', 'bbp_digest_init' ); 
    6683 
    6784/** 
     
    174191} 
    175192add_action( 'bbp_user_edit_after', 'bbp_digest_bbp_profile_fields' ); 
     193 
     194/** 
     195 * Show one-click subscription on a single forum 
     196 * 
     197 * @since 2.0 
     198 */ 
     199function bbp_digest_one_click_subscription() { 
     200    /* Load translations */ 
     201    bbp_digest_load_textdomain(); 
     202    /* Load file with template function */ 
     203    require_once( dirname( __FILE__ ) . '/inc/one-click-template.php' ); 
     204    /* Display template */ 
     205    bbp_digest_display_one_click_subscription(); 
     206} 
     207 
     208/** 
     209 * Handle one-click subscription submission 
     210 * 
     211 * @since 2.0 
     212 */ 
     213function bbp_digest_one_click_ajax_handle() { 
     214    /* Load file with function for saving */ 
     215    require_once( dirname( __FILE__ ) . '/inc/one-click-handle.php' ); 
     216    /* Do handling */ 
     217    bbp_digest_do_one_click_ajax_handle(); 
     218} 
     219 
     220/** 
     221 * Show Javascript in a head of a page 
     222 * 
     223 * @since 2.0 
     224 */ 
     225function bbp_digest_head_scripts() { 
     226    ?> 
     227    <script type="text/javascript"> 
     228        /* <![CDATA[ */ 
     229        var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>'; 
     230        /* ]]> */ 
     231    </script> 
     232    <?php 
     233} 
Note: See TracChangeset for help on using the changeset viewer.