Commit df6be05b authored by KR Moorhouse's avatar KR Moorhouse Committed by Kenneth Hall

Issue#3739

parent 39fb981b
......@@ -10,7 +10,7 @@
},
{
"title":"MailChimp",
"image":"assets/img/add-ons/mailchimp-for-ninja-forms.png",
"image":"assets/img/add-ons/mail-chimp.png",
"content":"Quickly create newsletter signup forms for your MailChimp account.",
"link":"https://ninjaforms.com/extensions/mail-chimp/?utm_medium=plugin&utm_source=plugin-addons-page&utm_campaign=Ninja+Forms+Addons+Page&utm_content=MailChimp",
"plugin":"ninja-forms-mail-chimp/ninja-forms-mail-chimp.php",
......
......@@ -28,20 +28,31 @@ final class NF_Admin_Menus_Addons extends NF_Abstracts_Submenu
public function display()
{
//wp_enqueue_style( 'nf-admin-addons', Ninja_Forms::$url . 'assets/css/admin-addons.css' );
// $items = wp_remote_get( 'https://ninjaforms.com/?extend_feed=jlhrbgf89734go7387o4g3h' );
// $items = wp_remote_retrieve_body( $items );
$items = file_get_contents( Ninja_Forms::$dir . '/deprecated/addons-feed.json' );
$items = json_decode( $items, true );
// Fetch our marketing feed.
$saved = get_option( 'ninja_forms_addons_feed', false );
// If we got back nothing...
if ( ! $saved ) {
// Default to the in-app file.
$items = file_get_contents( Ninja_Forms::$dir . '/deprecated/addons-feed.json' );
$items = json_decode( $items, true );
} // Otherwise... (We did get something from the db.)
else {
// Use the data we fetched.
$items = json_decode( $saved, true );
}
//shuffle( $items );
$notices = array();
foreach ($items as $item) {
foreach ($items as &$item) {
$plugin_data = array();
if( !empty( $item['plugin'] ) && file_exists( WP_PLUGIN_DIR.'/'.$item['plugin'] ) ){
$plugin_data = get_plugin_data( WP_PLUGIN_DIR.'/'.$item['plugin'], false, true );
}
if ( ! file_exists( Ninja_Forms::$dir . '/' . $item[ 'image' ] ) ) {
$item[ 'image' ] = 'assets/img/add-ons/placeholder.png';
}
$version = isset ( $plugin_data['Version'] ) ? $plugin_data['Version'] : '';
......
......@@ -9,7 +9,7 @@ return apply_filters( 'ninja_forms_available_actions', array(
'link' => 'https://ninjaforms.com/extensions/mail-chimp/?utm_medium=plugin&utm_source=plugin&utm_campaign=Ninja+Forms+Actions+Drawer&utm_content=MailChimp',
'plugin_path' => 'ninja-forms-mail-chimp/ninja-forms-mail-chimp.php',
'modal_content' => '<div class="available-action-modal">
<img src="' . Ninja_Forms::$url . 'assets/img/add-ons/mailchimp-for-ninja-forms.png"/>
<img src="' . Ninja_Forms::$url . 'assets/img/add-ons/mail-chimp.png"/>
<p>In order to use this action, you need MailChimp for Ninja Forms.</p>
<p>The MailChimp extension allows you to quickly create newsletter signup forms for your MailChimp account using the power and flexibility that Ninja Forms provides.</p>
<div class="actions">
......
......@@ -81,7 +81,7 @@ $ads = array(
'type' => 'ad',
'modal-title' => 'Get MailChimp for Ninja Forms',
'modal-content' => '<div class="modal-template">
<img src="' . Ninja_Forms::$url . 'assets/img/add-ons/mailchimp-for-ninja-forms.png"/>
<img src="' . Ninja_Forms::$url . 'assets/img/add-ons/mail-chimp.png"/>
<p>In order to use this template, you need MailChimp for Ninja Forms.</p>
<p>The MailChimp extension allows you to quickly create newsletter signup forms for your MailChimp account using the power and flexibility that Ninja Forms provides.</p>
<div class="actions">
......
......@@ -119,6 +119,10 @@
<!-- Section: Memberships -->
<script id="tmpl-nf-memberships" type="text/template">
<?php
$saved = get_option( 'ninja_forms_memberships_feed', false );
if ( ! $saved ) {
?>
<div class="widget widget-memberships">
<div class="pricing-container">
<div class="pricing-block widget">
......@@ -222,6 +226,11 @@
<div><em><?php _e( 'All plans include a 14 day money back guarantee.', 'ninja-forms' ); ?></em></div>
<div><?php _e( 'Requires a current active license and subject to our', 'ninja-forms' ); ?> <a target="_blank" href="https://ninjaforms.com/terms-conditions/?utm_medium=plugin&utm_source=plugin-dashboard&utm_campaign=Ninja+Forms+Memberships&utm_content=Terms+Conditions"><?php _e( 'Terms & Conditions', 'ninja-forms' ); ?></a>.</div>
</div>
<?php
} else {
echo( $saved );
}
?>
</script>
<!-- Widget: Forms -->
......
......@@ -974,12 +974,24 @@ if( get_option( 'ninja_forms_load_deprecated', FALSE ) && ! ( isset( $_POST[ 'nf
}
add_action( 'nf_optin_cron', 'nf_optin_update_environment_vars' );
// Custom Cron Recurrences
/**
* Function to register our Custom Cron Recurrences.
*
* @param $schedules (Array) The available cron recurrences.
* @return (Array) The filtered cron recurrences.
*
* @since
* @updated UPDATE_VERSION_ON_MERGE
*/
function nf_custom_cron_job_recurrence( $schedules ) {
$schedules[ 'nf-monthly' ] = array(
'display' => __( 'Once per month', 'ninja-forms' ),
'interval' => 2678400,
);
$schedules[ 'nf-weekly' ] = array(
'display' => __( 'Once per week', 'ninja-forms' ),
'interval' => 604800,
);
return $schedules;
}
add_filter( 'cron_schedules', 'nf_custom_cron_job_recurrence' );
......@@ -990,6 +1002,42 @@ if( get_option( 'ninja_forms_load_deprecated', FALSE ) && ! ( isset( $_POST[ 'nf
wp_schedule_event( current_time( 'timestamp' ), 'nf-monthly', 'nf_optin_cron' );
}
}
add_action( 'wp', 'nf_optin_send_admin_email_cron_job' );
/**
* Function called via weekly wp_cron to update our marketing feeds.
*
* @since UPDATE_VERSION_ON_MERGE
*/
function nf_update_marketing_feed() {
// Fetch our membership data.
$data = wp_remote_get( 'http://api.ninjaforms.com/feeds/?fetch=memberships' );
// If we got a valid response...
if ( 200 == $data[ 'response' ][ 'code' ] ) {
// Save the data to our option.
$data = wp_remote_retrieve_body( $data );
update_option( 'ninja_forms_memberships_feed', $data, false );
}
// Fetch our addon data.
$data = wp_remote_get( 'http://api.ninjaforms.com/feeds/?fetch=addons' );
// If we got a valid response...
if ( 200 == $data[ 'response' ][ 'code' ] ) {
// Save the data to our option.
$data = wp_remote_retrieve_body( $data );
update_option( 'ninja_forms_addons_feed', $data, false );
}
}
add_action( 'nf_marketing_feed_cron', 'nf_update_marketing_feed' );
/**
* Function called by our marketing feed cron.
*
* @since UPDATE_VERSION_ON_MERGE
*/
function nf_marketing_feed_cron_job() {
if ( ! wp_next_scheduled( 'nf_marketing_feed_cron' ) ) {
wp_schedule_event( current_time( 'timestamp' ), 'nf-weekly', 'nf_marketing_feed_cron' );
}
}
add_action( 'wp', 'nf_marketing_feed_cron_job' );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment