Subscribe2 - Version 10.13

Version Description

Download this release

Release Info

Developer tanaylakhani
Plugin Icon 128x128 Subscribe2
Version 10.13
Comparing to
See all releases

Code changes from version 10.12 to 10.13

ChangeLog.txt CHANGED
@@ -1,3 +1,9 @@
 
 
 
 
 
 
1
  = 10.12 =
2
 
3
  * Popup customization templates selection
1
+ = 10.13 =
2
+
3
+ * Uninstall Readygraph Option
4
+ * Daily digest
5
+ * Real time post update to all the subscribers
6
+
7
  = 10.12 =
8
 
9
  * Popup customization templates selection
ReadMe.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_butt
4
  Tags: posts, subscription, email, subscribe, notify, notification
5
  Requires at least: 3.3
6
  Tested up to: 3.9.1
7
- Stable tag: 10.12
8
  License: GPL3
9
 
10
  Sends a list of subscribers an email notification when new posts are published to your blog. Automate user growth through ReadyGraph integration.
4
  Tags: posts, subscription, email, subscribe, notify, notification
5
  Requires at least: 3.3
6
  Tested up to: 3.9.1
7
+ Stable tag: 10.13
8
  License: GPL3
9
 
10
  Sends a list of subscribers an email notification when new posts are published to your blog. Automate user growth through ReadyGraph integration.
classes/class-s2-admin.php CHANGED
@@ -11,8 +11,13 @@ class s2_admin extends s2class {
11
  add_action("admin_print_scripts-$s2user", array(&$this, 'checkbox_form_js'));
12
  add_action("admin_print_styles-$s2user", array(&$this, 'user_admin_css'));
13
  add_action('load-' . $s2user, array(&$this, 'user_help'));
14
- global $menu_slug;
15
- $s2readygraph = add_submenu_page('s2', __('Readygraph App', 'subscribe2'), __('Readygraph App', 'subscribe2'), apply_filters('s2_capability', "manage_options", 'readygraph'), $menu_slug, array(&$this, 'readygraph_menu'));
 
 
 
 
 
16
  //add_action("admin_print_scripts-$s2readygraph", array(&$this, 'readygraph_js'));
17
 
18
  $s2subscribers = add_submenu_page('s2', __('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), apply_filters('s2_capability', "manage_options", 'manage'), 's2_tools', array(&$this, 'subscribers_menu'));
@@ -159,7 +164,7 @@ class s2_admin extends s2class {
159
  /**
160
  Enqueue jQuery for ReadyGraph
161
  */
162
- function readygraph_js() {
163
  wp_enqueue_script('jquery');
164
  wp_register_script('s2_readygraph', S2URL . 'include/s2_readygraph' . $this->script_debug . '.js', array('jquery'), '1.0');
165
  wp_enqueue_script('s2_readygraph');
@@ -170,7 +175,7 @@ class s2_admin extends s2class {
170
  'passwordmatch' => __('Password is not matching!', 'subscribe2')
171
  ) );
172
  } // end readygraph_js()
173
-
174
  /**
175
  Adds a links directly to the settings page from the plugin page
176
  */
11
  add_action("admin_print_scripts-$s2user", array(&$this, 'checkbox_form_js'));
12
  add_action("admin_print_styles-$s2user", array(&$this, 'user_admin_css'));
13
  add_action('load-' . $s2user, array(&$this, 'user_help'));
14
+ if( file_exists(dirname(plugin_dir_path( __FILE__ ) ).'/readygraph-extension.php')) {
15
+ global $menu_slug;
16
+ $s2readygraph = add_submenu_page('s2', __('Readygraph App', 'subscribe2'), __('Readygraph App', 'subscribe2'), apply_filters('s2_capability', "manage_options", 'readygraph'), $menu_slug, array(&$this, 'readygraph_menu'));
17
+ }
18
+ else {
19
+ }
20
+
21
  //add_action("admin_print_scripts-$s2readygraph", array(&$this, 'readygraph_js'));
22
 
23
  $s2subscribers = add_submenu_page('s2', __('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), apply_filters('s2_capability', "manage_options", 'manage'), 's2_tools', array(&$this, 'subscribers_menu'));
164
  /**
165
  Enqueue jQuery for ReadyGraph
166
  */
167
+ /* function readygraph_js() {
168
  wp_enqueue_script('jquery');
169
  wp_register_script('s2_readygraph', S2URL . 'include/s2_readygraph' . $this->script_debug . '.js', array('jquery'), '1.0');
170
  wp_enqueue_script('s2_readygraph');
175
  'passwordmatch' => __('Password is not matching!', 'subscribe2')
176
  ) );
177
  } // end readygraph_js()
178
+ */
179
  /**
180
  Adds a links directly to the settings page from the plugin page
181
  */
extension/readygraph/admin.php CHANGED
@@ -12,7 +12,7 @@
12
  * @copyright 2014 Your Name or Company Name
13
  */
14
 
15
- function gCF_changeAccount(){
16
  $app_id = get_option('readygraph_application_id');
17
  wp_remote_get( "http://readygraph.com/api/v1/tracking?event=disconnect_readygraph&app_id=$app_id" );
18
  delete_option('readygraph_access_token');
@@ -26,13 +26,39 @@ delete_option('readygraph_auto_select_all');
26
  delete_option('readygraph_enable_notification');
27
  delete_option('readygraph_enable_branding');
28
  delete_option('readygraph_send_blog_updates');
 
29
  delete_option('readygraph_popup_template');
30
  /*delete_option('readygraph_popup_template_background');
31
  delete_option('readygraph_popup_template_text');
32
  delete_option('readygraph_popup_template_button');*/
33
- wp_clear_scheduled_hook( 'rg_gCF_cron_hook' );
34
  }
35
- if(isset($_GET["action"]) && base64_decode($_GET["action"]) == "changeaccount")gCF_changeAccount();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  global $main_plugin_title;
37
  if (!get_option('readygraph_access_token') || strlen(get_option('readygraph_access_token')) <= 0) {
38
  if (isset($_POST["readygraph_access_token"])) update_option('readygraph_access_token', $_POST["readygraph_access_token"]);
@@ -46,6 +72,7 @@ wp_clear_scheduled_hook( 'rg_gCF_cron_hook' );
46
  if (isset($_POST["readygraph_auto_select_all"])) update_option('readygraph_auto_select_all', $_POST["selectAll"]);
47
  if (isset($_POST["readygraph_enable_branding"])) update_option('readygraph_enable_branding', 'false');
48
  if (isset($_POST["readygraph_send_blog_updates"])) update_option('readygraph_send_blog_updates', 'true');
 
49
  if (isset($_POST["readygraph_popup_template"])) update_option('readygraph_popup_template', 'default-template');
50
  /*if (isset($_POST["readygraph_popup_template_background"])) update_option('readygraph_popup_template_background', '#ffffff');
51
  if (isset($_POST["readygraph_popup_template_text"])) update_option('readygraph_popup_template_text', '#000000');
@@ -67,6 +94,7 @@ wp_clear_scheduled_hook( 'rg_gCF_cron_hook' );
67
  if (isset($_POST["readygraph_auto_select_all"])) update_option('readygraph_auto_select_all', $_POST["selectAll"]);
68
  if (isset($_POST["readygraph_enable_branding"])) update_option('readygraph_enable_branding', $_POST["branding"]);
69
  if (isset($_POST["readygraph_send_blog_updates"])) update_option('readygraph_send_blog_updates', $_POST["blog_updates"]);
 
70
  if (isset($_POST["readygraph_popup_template"])) update_option('readygraph_popup_template', $_POST["popup_template"]);
71
  /*if (isset($_POST["readygraph_popup_template_background"])) update_option('readygraph_popup_template_background', $_POST["readygraph_popup_template_background"]);
72
  if (isset($_POST["readygraph_popup_template_text"])) update_option('readygraph_popup_template_text', $_POST["readygraph_popup_template_text"]);
@@ -97,6 +125,7 @@ wp_clear_scheduled_hook( 'rg_gCF_cron_hook' );
97
  <input type="hidden" name="readygraph_auto_select_all" value="<?php echo get_option('readygraph_auto_select_all', 'true') ?>">
98
  <input type="hidden" name="readygraph_enable_branding" value="<?php echo get_option('readygraph_enable_branding', 'false') ?>">
99
  <input type="hidden" name="readygraph_send_blog_updates" value="<?php echo get_option('readygraph_send_blog_updates', 'true') ?>">
 
100
  <input type="hidden" name="readygraph_popup_template" value="<?php echo get_option('readygraph_popup_template', 'default-template') ?>">
101
  <!--<input type="hidden" name="readygraph_popup_template_background" value="<?php //echo get_option('readygraph_popup_template_background', '') ?>">
102
  <input type="hidden" name="readygraph_popup_template_text" value="<?php //echo get_option('readygraph_popup_template_text', '') ?>">
@@ -160,6 +189,7 @@ If you have questions or concerns contact us anytime at <a href="mailto:info@rea
160
  <ul class="dropdown-menu">
161
  <li><a class="change-account" href="#">Change Account</a></li>
162
  <li><a class="disconnect" href="<?php $current_url = explode("&", $_SERVER['REQUEST_URI']); echo $current_url[0];?>&action=<?php echo base64_encode("changeaccount");?>">Disconnect</a></li>
 
163
  </ul>
164
  </div>
165
  <div class="btn-group pull-right" style="margin: 8px 10px 0 0;">
@@ -239,11 +269,16 @@ If you have questions or concerns contact us anytime at <a href="mailto:info@rea
239
  <option value="true">YES</option>
240
  <option value="false">NO</option>
241
  </select></p><br />
242
- <p>Include blog updates in weekly email digest of Readygraph:
243
  <select class="blog_updates" name="blog_updates" class="form-control">
244
  <option value="true">YES</option>
245
  <option value="false">NO</option>
246
  </select></p><br />
 
 
 
 
 
247
  <p>Popup Templates:
248
  <select class="popup_template" name="popup_template" class="form-control">
249
  <option value="default-template">Default Template</option>
@@ -357,6 +392,7 @@ If you have questions or concerns contact us anytime at <a href="mailto:info@rea
357
  $('.selectAll').val($('[name="readygraph_auto_select_all"]').val());
358
  $('.branding').val($('[name="readygraph_enable_branding"]').val());
359
  $('.blog_updates').val($('[name="readygraph_send_blog_updates"]').val());
 
360
  $('.popup_template').val($('[name="readygraph_popup_template"]').val());
361
 
362
  //$('[name="readygraph_ad_format"][value="' + $('[name="_readygraph_ad_format"]').val() + '"]').parent().click();
@@ -381,6 +417,9 @@ If you have questions or concerns contact us anytime at <a href="mailto:info@rea
381
  $('.result').text('Insight');
382
  }
383
  }
 
 
 
384
  });
385
  }
386
  }
@@ -388,6 +427,37 @@ If you have questions or concerns contact us anytime at <a href="mailto:info@rea
388
 
389
  // Manage OAuth 2.0 Results
390
  //
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  window.setCode = function(code) {
392
  $('.rgw-fb-login-button-iframe').hide();
393
  $('div.authenticate').hide();
12
  * @copyright 2014 Your Name or Company Name
13
  */
14
 
15
+ function s2_changeAccount(){
16
  $app_id = get_option('readygraph_application_id');
17
  wp_remote_get( "http://readygraph.com/api/v1/tracking?event=disconnect_readygraph&app_id=$app_id" );
18
  delete_option('readygraph_access_token');
26
  delete_option('readygraph_enable_notification');
27
  delete_option('readygraph_enable_branding');
28
  delete_option('readygraph_send_blog_updates');
29
+ delete_option('readygraph_send_real_time_post_updates');
30
  delete_option('readygraph_popup_template');
31
  /*delete_option('readygraph_popup_template_background');
32
  delete_option('readygraph_popup_template_text');
33
  delete_option('readygraph_popup_template_button');*/
34
+ //wp_clear_scheduled_hook( 'rg_gCF_cron_hook' );
35
  }
36
+ function s2_deleteAccount(){
37
+ $app_id = get_option('readygraph_application_id');
38
+ wp_remote_get( "http://readygraph.com/api/v1/tracking?event=uninstall_readygraph&app_id=$app_id" );
39
+ delete_option('readygraph_access_token');
40
+ delete_option('readygraph_application_id');
41
+ delete_option('readygraph_refresh_token');
42
+ delete_option('readygraph_email');
43
+ delete_option('readygraph_settings');
44
+ delete_option('readygraph_delay');
45
+ delete_option('readygraph_enable_sidebar');
46
+ delete_option('readygraph_auto_select_all');
47
+ delete_option('readygraph_enable_notification');
48
+ delete_option('readygraph_enable_branding');
49
+ delete_option('readygraph_send_blog_updates');
50
+ delete_option('readygraph_send_real_time_post_updates');
51
+ delete_option('readygraph_popup_template');
52
+ /*delete_option('readygraph_popup_template_background');
53
+ delete_option('readygraph_popup_template_text');
54
+ delete_option('readygraph_popup_template_button');*/
55
+ //wp_clear_scheduled_hook( 'rg_gCF_cron_hook' );
56
+ $dir = plugin_dir_path( __FILE__ );
57
+ s2_rrmdir($dir);
58
+ }
59
+
60
+ if(isset($_GET["action"]) && base64_decode($_GET["action"]) == "changeaccount")s2_changeAccount();
61
+ if(isset($_GET["action"]) && base64_decode($_GET["action"]) == "deleteaccount")s2_deleteAccount();
62
  global $main_plugin_title;
63
  if (!get_option('readygraph_access_token') || strlen(get_option('readygraph_access_token')) <= 0) {
64
  if (isset($_POST["readygraph_access_token"])) update_option('readygraph_access_token', $_POST["readygraph_access_token"]);
72
  if (isset($_POST["readygraph_auto_select_all"])) update_option('readygraph_auto_select_all', $_POST["selectAll"]);
73
  if (isset($_POST["readygraph_enable_branding"])) update_option('readygraph_enable_branding', 'false');
74
  if (isset($_POST["readygraph_send_blog_updates"])) update_option('readygraph_send_blog_updates', 'true');
75
+ if (isset($_POST["readygraph_send_real_time_post_updates"])) update_option('readygraph_send_real_time_post_updates', 'false');
76
  if (isset($_POST["readygraph_popup_template"])) update_option('readygraph_popup_template', 'default-template');
77
  /*if (isset($_POST["readygraph_popup_template_background"])) update_option('readygraph_popup_template_background', '#ffffff');
78
  if (isset($_POST["readygraph_popup_template_text"])) update_option('readygraph_popup_template_text', '#000000');
94
  if (isset($_POST["readygraph_auto_select_all"])) update_option('readygraph_auto_select_all', $_POST["selectAll"]);
95
  if (isset($_POST["readygraph_enable_branding"])) update_option('readygraph_enable_branding', $_POST["branding"]);
96
  if (isset($_POST["readygraph_send_blog_updates"])) update_option('readygraph_send_blog_updates', $_POST["blog_updates"]);
97
+ if (isset($_POST["readygraph_send_real_time_post_updates"])) update_option('readygraph_send_real_time_post_updates', $_POST["real_time_post_update"]);
98
  if (isset($_POST["readygraph_popup_template"])) update_option('readygraph_popup_template', $_POST["popup_template"]);
99
  /*if (isset($_POST["readygraph_popup_template_background"])) update_option('readygraph_popup_template_background', $_POST["readygraph_popup_template_background"]);
100
  if (isset($_POST["readygraph_popup_template_text"])) update_option('readygraph_popup_template_text', $_POST["readygraph_popup_template_text"]);
125
  <input type="hidden" name="readygraph_auto_select_all" value="<?php echo get_option('readygraph_auto_select_all', 'true') ?>">
126
  <input type="hidden" name="readygraph_enable_branding" value="<?php echo get_option('readygraph_enable_branding', 'false') ?>">
127
  <input type="hidden" name="readygraph_send_blog_updates" value="<?php echo get_option('readygraph_send_blog_updates', 'true') ?>">
128
+ <input type="hidden" name="readygraph_send_real_time_post_updates" value="<?php echo get_option('readygraph_send_real_time_post_updates', 'false') ?>">
129
  <input type="hidden" name="readygraph_popup_template" value="<?php echo get_option('readygraph_popup_template', 'default-template') ?>">
130
  <!--<input type="hidden" name="readygraph_popup_template_background" value="<?php //echo get_option('readygraph_popup_template_background', '') ?>">
131
  <input type="hidden" name="readygraph_popup_template_text" value="<?php //echo get_option('readygraph_popup_template_text', '') ?>">
189
  <ul class="dropdown-menu">
190
  <li><a class="change-account" href="#">Change Account</a></li>
191
  <li><a class="disconnect" href="<?php $current_url = explode("&", $_SERVER['REQUEST_URI']); echo $current_url[0];?>&action=<?php echo base64_encode("changeaccount");?>">Disconnect</a></li>
192
+ <li><a class="delete" href="<?php $current_url = explode("&", $_SERVER['REQUEST_URI']); echo $current_url[0];?>&action=<?php echo base64_encode("deleteaccount");?>">Delete ReadyGraph</a></li>
193
  </ul>
194
  </div>
195
  <div class="btn-group pull-right" style="margin: 8px 10px 0 0;">
269
  <option value="true">YES</option>
270
  <option value="false">NO</option>
271
  </select></p><br />
272
+ <p>Include blog updates in daily/weekly email digest of Readygraph:
273
  <select class="blog_updates" name="blog_updates" class="form-control">
274
  <option value="true">YES</option>
275
  <option value="false">NO</option>
276
  </select></p><br />
277
+ <p>Send Real Time Post Updates to your subscribers:
278
+ <select class="real_time_post_update" name="real_time_post_update" class="form-control">
279
+ <option value="true">YES</option>
280
+ <option value="false">NO</option>
281
+ </select></p><br />
282
  <p>Popup Templates:
283
  <select class="popup_template" name="popup_template" class="form-control">
284
  <option value="default-template">Default Template</option>
392
  $('.selectAll').val($('[name="readygraph_auto_select_all"]').val());
393
  $('.branding').val($('[name="readygraph_enable_branding"]').val());
394
  $('.blog_updates').val($('[name="readygraph_send_blog_updates"]').val());
395
+ $('.real_time_post_update').val($('[name="readygraph_send_real_time_post_updates"]').val());
396
  $('.popup_template').val($('[name="readygraph_popup_template"]').val());
397
 
398
  //$('[name="readygraph_ad_format"][value="' + $('[name="_readygraph_ad_format"]').val() + '"]').parent().click();
417
  $('.result').text('Insight');
418
  }
419
  }
420
+ , error: function (response) {
421
+ refresh_access_token();
422
+ }
423
  });
424
  }
425
  }
427
 
428
  // Manage OAuth 2.0 Results
429
  //
430
+ function refresh_access_token() {
431
+ var refresh_token = $('[name="readygraph_refresh_token"]').val();
432
+ if (refresh_token) {
433
+ $('div.authenticate').hide();
434
+ $('div.authenticating').show();
435
+ $('div.authenticated').hide();
436
+
437
+ $.ajax({
438
+ url: resourceHost + '/oauth/access_token'
439
+ , data: {
440
+ grant_type: 'refresh_token',
441
+ refresh_token: $('[name="readygraph_refresh_token"]').val(),
442
+ redirect_uri: encodeURIComponent(location.href.replace('#' + location.hash,"")),
443
+ client_id: settings.clientId
444
+ }
445
+ , method: 'POST'
446
+ , success: function (response) {
447
+ $('[name="readygraph_access_token"]').val(response.access_token);
448
+ $('[name="readygraph_refresh_token"]').val(response.refresh_token);
449
+ window.setAccessToken(response.access_token);
450
+ $('.result').text(response.data.subscribers + ((response.data.subscribers == 0) ? ' Subscriber' : ' Subscribers'));
451
+ }
452
+ , error: function (response) {
453
+ alert('We couldn\'t authenticate your account. Please check your internet connection.');
454
+ $('div.authenticate').show();
455
+ $('div.authenticating').hide();
456
+ $('div.authenticated').hide();
457
+ }
458
+ });
459
+ }
460
+ }
461
  window.setCode = function(code) {
462
  $('.rgw-fb-login-button-iframe').hide();
463
  $('div.authenticate').hide();
extension/readygraph/assets/Thumbs.db DELETED
Binary file
readygraph-extension.php CHANGED
@@ -51,9 +51,10 @@ function s2_myajax_submit() {
51
  add_action('admin_notices', 'add_readygraph_plugin_warning');
52
  add_action('wp_footer', 'readygraph_client_script_head');
53
  add_action('admin_init', 'on_plugin_activated_readygraph_s2_redirect');
54
-
55
- add_filter( 'cron_schedules', 'readygraph_s2_cron_intervals' );
56
  add_option('readygraph_connect_notice','true');
 
 
 
57
  //add_action( 'wp_ajax_add', 'add' );
58
  function readygraph_s2_cron_intervals( $schedules ) {
59
  $schedules['weekly'] = array( // Provide the programmatic name to be used in code
@@ -83,7 +84,7 @@ function rg_s2_cron_exec() {
83
  $readygraph_email = get_option('readygraph_email', '');
84
  // wp_mail($readygraph_email, 'Automatic email', 'Hello, this is an automatically scheduled email from WordPress.');
85
  global $wpdb;
86
- $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified DESC LIMIT 5";
87
 
88
  global $wpdb;
89
  $recentposts = $wpdb->get_results($query);
@@ -92,28 +93,79 @@ function rg_s2_cron_exec() {
92
  echo "<ul>";
93
  $postdata = "";
94
  $postdatalinks = "";
 
95
  foreach($recentposts as $post) {
 
96
  $postdata .= $post->post_title . ", ";
97
  $postdatalinks .= get_permalink($post->ID) . ", ";
 
 
98
  $url = 'http://readygraph.com/api/v1/post.json/';
99
- $response = wp_remote_post($url, array( 'body' => array('is_wordpress'=>1, 'message' => rtrim($postdata, ", "), 'message_link' => rtrim($postdatalinks, ", "),'client_key' => get_option('readygraph_application_id'), 'email' => get_option('readygraph_email'))));
100
 
101
  if ( is_wp_error( $response ) ) {
102
  $error_message = $response->get_error_message();
103
- echo "Something went wrong: $error_message";
104
  } else {
105
- echo 'Response:<pre>';
106
- print_r( $response );
107
- echo '</pre>';
108
  }
109
  echo "</ul>";
110
 
111
- //endif;
112
-
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
 
 
114
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
 
116
- function rg_gCF_popup_options_enqueue_scripts() {
 
 
 
117
  if ( get_option('readygraph_popup_template') == 'default-template' ) {
118
  wp_enqueue_style( 'default-template', plugin_dir_url( __FILE__ ) .'extension/readygraph/assets/css/default-popup.css' );
119
  }
@@ -156,13 +208,49 @@ function rg_gCF_popup_options_enqueue_scripts() {
156
  wp_enqueue_style( 'custom-template', plugin_dir_url( __FILE__ ) .'extension/readygraph/assets/css/custom-popup.css' );
157
  }
158
  }
159
- add_action( 'admin_enqueue_scripts', 'rg_gCF_popup_options_enqueue_scripts' );
160
- add_action( 'wp_enqueue_scripts', 'rg_gCF_popup_options_enqueue_scripts' );
161
- add_action( 'admin_enqueue_scripts', 'mw_enqueue_color_picker' );
162
- function mw_enqueue_color_picker( $hook_suffix ) {
 
163
  // first check that $hook_suffix is appropriate for your admin page
164
  wp_enqueue_style( 'wp-color-picker' );
165
- wp_enqueue_script( 'my-script-handle', plugins_url('/extension/readygraph/assets/js/my-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  }
 
 
167
 
168
  ?>
51
  add_action('admin_notices', 'add_readygraph_plugin_warning');
52
  add_action('wp_footer', 'readygraph_client_script_head');
53
  add_action('admin_init', 'on_plugin_activated_readygraph_s2_redirect');
 
 
54
  add_option('readygraph_connect_notice','true');
55
+ /*
56
+ add_filter( 'cron_schedules', 'readygraph_s2_cron_intervals' );
57
+
58
  //add_action( 'wp_ajax_add', 'add' );
59
  function readygraph_s2_cron_intervals( $schedules ) {
60
  $schedules['weekly'] = array( // Provide the programmatic name to be used in code
84
  $readygraph_email = get_option('readygraph_email', '');
85
  // wp_mail($readygraph_email, 'Automatic email', 'Hello, this is an automatically scheduled email from WordPress.');
86
  global $wpdb;
87
+ $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' and post_modified between date_sub(now(),INTERVAL 1 WEEK) and now() ORDER BY post_modified DESC LIMIT 5";
88
 
89
  global $wpdb;
90
  $recentposts = $wpdb->get_results($query);
93
  echo "<ul>";
94
  $postdata = "";
95
  $postdatalinks = "";
96
+ $postexcerpts = "";
97
  foreach($recentposts as $post) {
98
+ $post_content = get_posts($post->ID);
99
  $postdata .= $post->post_title . ", ";
100
  $postdatalinks .= get_permalink($post->ID) . ", ";
101
+ $postexcerpts .= wp_trim_words( $post_content->post_content ) . ", ";
102
+ }
103
  $url = 'http://readygraph.com/api/v1/post.json/';
104
+ $response = wp_remote_post($url, array( 'body' => array('is_wordpress'=>1, 'message' => rtrim($postdata, ", "), 'message_link' => rtrim($postdatalinks, ", "), 'message_excerpt' => rtrim($postexcerpts, ", "),'client_key' => get_option('readygraph_application_id'), 'email' => get_option('readygraph_email'))));
105
 
106
  if ( is_wp_error( $response ) ) {
107
  $error_message = $response->get_error_message();
108
+ //echo "Something went wrong: $error_message";
109
  } else {
110
+ //echo 'Response:<pre>';
111
+ //print_r( $response );
112
+ //echo '</pre>';
113
  }
114
  echo "</ul>";
115
 
116
+ //endif
117
+ }
118
+
119
+
120
+ add_action( 'rg_s2_daily_cron_hook', 'rg_s2_daily_cron_exec' );
121
+ $send_daily_digest = get_option('readygraph_send_daily_digest');
122
+ if ($send_daily_digest == 'true'){
123
+ if( !wp_next_scheduled( 'rg_s2_daily_cron_hook' )) {
124
+ wp_schedule_event( time(), 'daily', 'rg_s2_daily_cron_hook' );
125
+ }
126
+ }
127
+ else
128
+ {
129
+ //do nothing
130
  }
131
+ if ($send_daily_digest == 'false'){
132
+ wp_clear_scheduled_hook( 'rg_s2_daily_cron_hook' );
133
  }
134
+ function rg_s2_daily_cron_exec() {
135
+ global $wpdb;
136
+ $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' and post_modified between date_sub(now(),INTERVAL 1 day) and now() ORDER BY post_modified DESC LIMIT 5";
137
+
138
+ global $wpdb;
139
+ $recentposts = $wpdb->get_results($query);
140
+
141
+ echo "<h2> Recently Updated</h2>";
142
+ echo "<ul>";
143
+ $postdata = "";
144
+ $postdatalinks = "";
145
+ $postexcerpts = "";
146
+ foreach($recentposts as $post) {
147
+ $post_content = get_posts($post->ID);
148
+ $postdata .= $post->post_title . ", ";
149
+ $postdatalinks .= get_permalink($post->ID) . ", ";
150
+ $postexcerpts .= wp_trim_words( $post_content->post_content ) . ", ";
151
+ }
152
+ $url = 'http://readygraph.com/api/v1/post.json/';
153
+ $response = wp_remote_post($url, array( 'body' => array('is_wordpress'=>1, 'message' => rtrim($postdata, ", "), 'message_link' => rtrim($postdatalinks, ", "), 'message_excerpt' => rtrim($postexcerpts, ", "),'client_key' => get_option('readygraph_application_id'), 'email' => get_option('readygraph_email'))));
154
+
155
+ if ( is_wp_error( $response ) ) {
156
+ $error_message = $response->get_error_message();
157
+ //echo "Something went wrong: $error_message";
158
+ } else {
159
+ //echo 'Response:<pre>';
160
+ //print_r( $response );
161
+ //echo '</pre>';
162
+ }
163
+ echo "</ul>";
164
 
165
+ //endif
166
+ }
167
+ */
168
+ function rg_s2_popup_options_enqueue_scripts() {
169
  if ( get_option('readygraph_popup_template') == 'default-template' ) {
170
  wp_enqueue_style( 'default-template', plugin_dir_url( __FILE__ ) .'extension/readygraph/assets/css/default-popup.css' );
171
  }
208
  wp_enqueue_style( 'custom-template', plugin_dir_url( __FILE__ ) .'extension/readygraph/assets/css/custom-popup.css' );
209
  }
210
  }
211
+ add_action( 'admin_enqueue_scripts', 'rg_s2_popup_options_enqueue_scripts' );
212
+ add_action( 'wp_enqueue_scripts', 'rg_s2_popup_options_enqueue_scripts' );
213
+ add_action( 'admin_enqueue_scripts', 'rg_s2_enqueue_color_picker' );
214
+
215
+ function rg_s2_enqueue_color_picker( $hook_suffix ) {
216
  // first check that $hook_suffix is appropriate for your admin page
217
  wp_enqueue_style( 'wp-color-picker' );
218
+ wp_enqueue_script( 's2-script-handle', plugins_url('/extension/readygraph/assets/js/my-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
219
+ }
220
+
221
+ function s2_post_updated_send_email( $post_id ) {
222
+
223
+ // If this is just a revision, don't send the email.
224
+ if ( wp_is_post_revision( $post_id ) )
225
+ return;
226
+ if(get_option('readygraph_application_id') && strlen(get_option('readygraph_application_id')) > 0 && get_option('readygraph_send_blog_updates') == "true"){
227
+
228
+ $post_title = get_the_title( $post_id );
229
+ $post_url = get_permalink( $post_id );
230
+ $post_content = get_post($post_id);
231
+ if (get_option('readygraph_send_real_time_post_updates')=='true'){
232
+ $url = 'http://readygraph.com/api/v1/post.json/';
233
+ $response = wp_remote_post($url, array( 'body' => array('is_wordpress'=>1, 'is_realtime'=>1, 'message' => $post_title, 'message_link' => $post_url,'message_excerpt' => wp_trim_words( $post_content->post_content, 100 ),'client_key' => get_option('readygraph_application_id'), 'email' => get_option('readygraph_email'))));
234
+ }
235
+ else {
236
+ $response = wp_remote_post($url, array( 'body' => array('is_wordpress'=>1, 'message' => $post_title, 'message_link' => $post_url,'message_excerpt' => wp_trim_words( $post_content->post_content, 100 ),'client_key' => get_option('readygraph_application_id'), 'email' => get_option('readygraph_email'))));
237
+ }
238
+ if ( is_wp_error( $response ) ) {
239
+ $error_message = $response->get_error_message();
240
+ //echo "Something went wrong: $error_message";
241
+ } else {
242
+ //echo 'Response:<pre>';
243
+ //print_r( $response );
244
+ //echo '</pre>';
245
+ }
246
+ $app_id = get_option('readygraph_application_id');
247
+ wp_remote_get( "http://readygraph.com/api/v1/tracking?event=post_created&app_id=$app_id" );
248
+ }
249
+ else{
250
+ }
251
+
252
  }
253
+ add_action( 'publish_post', 's2_post_updated_send_email' );
254
+ add_action( 'publish_page', 's2_post_updated_send_email' );
255
 
256
  ?>
subscribe2.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Subscribe2
4
  Plugin URI: http://subscribe2.wordpress.com
5
  Description: Notifies an email list when new entries are posted.
6
- Version: 10.12
7
  Author: Matthew Robinson, tanaylakhani
8
  Author URI: http://subscribe2.wordpress.com
9
  Licence: GPL3
@@ -55,7 +55,7 @@ if ( is_plugin_active_for_network(plugin_basename(__FILE__)) ) {
55
 
56
  // our version number. Don't touch this or any line below
57
  // unless you know exactly what you are doing
58
- define( 'S2VERSION', '10.12' );
59
  define( 'S2PATH', trailingslashit(dirname(__FILE__)) );
60
  define( 'S2DIR', trailingslashit(dirname(plugin_basename(__FILE__))) );
61
  define( 'S2URL', plugin_dir_url(dirname(__FILE__)) . S2DIR );
@@ -81,8 +81,32 @@ if ( is_admin() ) {
81
 
82
  function s2_install() {
83
  add_option('rg_s2_plugin_do_activation_redirect', true);
 
 
 
 
 
 
84
  }
85
  register_activation_hook(__FILE__, 's2_install');
86
 
87
- include "readygraph-extension.php"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  ?>
3
  Plugin Name: Subscribe2
4
  Plugin URI: http://subscribe2.wordpress.com
5
  Description: Notifies an email list when new entries are posted.
6
+ Version: 10.13
7
  Author: Matthew Robinson, tanaylakhani
8
  Author URI: http://subscribe2.wordpress.com
9
  Licence: GPL3
55
 
56
  // our version number. Don't touch this or any line below
57
  // unless you know exactly what you are doing
58
+ define( 'S2VERSION', '10.13' );
59
  define( 'S2PATH', trailingslashit(dirname(__FILE__)) );
60
  define( 'S2DIR', trailingslashit(dirname(plugin_basename(__FILE__))) );
61
  define( 'S2URL', plugin_dir_url(dirname(__FILE__)) . S2DIR );
81
 
82
  function s2_install() {
83
  add_option('rg_s2_plugin_do_activation_redirect', true);
84
+ }
85
+ if( file_exists(plugin_dir_path( __FILE__ ).'/readygraph-extension.php' )) {
86
+ include "readygraph-extension.php";
87
+ }
88
+ else {
89
+
90
  }
91
  register_activation_hook(__FILE__, 's2_install');
92
 
93
+ function s2_rrmdir($dir) {
94
+ if (is_dir($dir)) {
95
+ $objects = scandir($dir);
96
+ foreach ($objects as $object) {
97
+ if ($object != "." && $object != "..") {
98
+ if (filetype($dir."/".$object) == "dir")
99
+ s2_rrmdir($dir."/".$object);
100
+ else unlink ($dir."/".$object);
101
+ }
102
+ }
103
+ reset($objects);
104
+ rmdir($dir);
105
+ }
106
+ $del_url = plugin_dir_path( __FILE__ );
107
+ unlink($del_url.'/readygraph-extension.php');
108
+ $setting_url="admin.php?page=s2";
109
+ echo'<script> window.location="'.admin_url($setting_url).'"; </script> ';
110
+ }
111
+
112
  ?>