function updates_disabled_email_user($obj) { $params = array(); $params['to'] = get_bloginfo('admin_email'); $params['subject'] = get_bloginfo('name') . __(': Datafeedr API Message (Product Set Update Failed)', DFRPS_DOMAIN); $params['message'] = "<p>" . __("This is an automated message generated by: ", DFRPS_DOMAIN) . get_bloginfo('wpurl') . "</p>"; $params['message'] .= "<p>" . __("An error occurred during the update of the ", DFRPS_DOMAIN); $params['message'] .= "<a href=\"" . admin_url('post.php?post=' . $this->set['ID'] . '&action=edit') . "\">" . $this->set['post_title'] . "</a>"; $params['message'] .= __(" product set.", DFRPS_DOMAIN) . "</p>"; if (isset($obj['dfrapi_api_error']['class'])) { // Have we exceeded the API request limit? if ($obj['dfrapi_api_error']['class'] == 'DatafeedrLimitExceededError') { $params['message'] .= "<p>" . __("You have used <strong>100%</strong> of your allocated Datafeedr API requests for this period. <u>You are no longer able to query the Datafeedr API to get product information.</u>", DFRPS_DOMAIN) . "</p>"; $params['message'] .= "<p><strong>" . __("What to do next?", DFRPS_DOMAIN) . "</strong></p>"; $params['message'] .= "<p>" . __("We strongly recommend that you upgrade to prevent your product information from becoming outdated.", DFRPS_DOMAIN) . "</p>"; $params['message'] .= "<p><a href=\"" . dfrapi_user_pages('change') . "?utm_source=email&utm_medium=link&utm_campaign=updatesdisablednotice\"><strong>" . __("UPGRADE NOW", DFRPS_DOMAIN) . "</strong></a></p>"; $params['message'] .= "<p>" . __("Upgrading only takes a minute. You will have <strong>instant access</strong> to more API requests. Any remaining credit for your current plan will be applied to your new plan.", DFRPS_DOMAIN) . "</p>"; $params['message'] .= "<p>" . __("You are under no obligation to upgrade. You may continue using your current plan for as long as you would like.", DFRPS_DOMAIN) . "</p>"; } else { $params['message'] .= "<p>" . __("The details of the error are below.", DFRPS_DOMAIN) . "</p>"; $params['message'] .= "<tt>"; $params['message'] .= "#################################################<br />"; $params['message'] .= __("CLASS: ", DFRPS_DOMAIN) . $obj['dfrapi_api_error']['class'] . "<br />"; $params['message'] .= __("CODE: ", DFRPS_DOMAIN) . $obj['dfrapi_api_error']['code'] . "<br />"; $params['message'] .= __("MESSAGE: ", DFRPS_DOMAIN) . $obj['dfrapi_api_error']['msg'] . "<br />"; if (!empty($obj['dfrapi_api_error']['params'])) { $query = dfrapi_display_api_request($obj['dfrapi_api_error']['params']); $params['message'] .= __("<br />QUERY:<br />", DFRPS_DOMAIN) . $query . "<br />"; } $params['message'] .= "#################################################"; $params['message'] .= "</tt>"; } } $params['message'] .= "<p>" . __("In the meantime, all product updates have been disabled on your site. After you fix this problem you will need to ", DFRPS_DOMAIN); $params['message'] .= "<a href=\"" . admin_url('admin.php?page=dfrps_configuration') . "\">" . __("enable updates again", DFRPS_DOMAIN) . ".</p>"; $params['message'] .= "<p>" . __("If you have any questions about your account, please ", DFRPS_DOMAIN); $params['message'] .= "<a href=\"" . DFRAPI_EMAIL_US_URL . "?utm_source=email&utm_medium=link&utm_campaign=updatesdisablednotice\">" . __("contact us", DFRPS_DOMAIN) . "</a>.</p>"; $params['message'] .= "<p>" . __("Thanks,<br />Eric & Stefan<br />The Datafeedr Team", DFRPS_DOMAIN) . "</p>"; $params['message'] .= "<p>"; $params['message'] .= "<a href=\"" . admin_url('admin.php?page=dfrapi_account') . "\">" . __("Account Information", DFRPS_DOMAIN) . "</a> | "; $params['message'] .= "<a href=\"" . dfrapi_user_pages('change') . "?utm_source=email&utm_medium=link&utm_campaign=updatesdisablednotice\">" . __("Upgrade Account", DFRPS_DOMAIN) . "</a> | "; $params['message'] .= "<a href=\"" . admin_url('admin.php?page=dfrps_configuration') . "\">" . __("Enable Updates", DFRPS_DOMAIN) . "</a>"; $params['message'] .= "</p>"; add_filter('wp_mail_content_type', 'dfrps_set_html_content_type'); wp_mail($params['to'], $params['subject'], $params['message']); remove_filter('wp_mail_content_type', 'dfrps_set_html_content_type'); }
function section_account_desc() { echo '<p><a href="' . dfrapi_user_pages('summary') . '?utm_source=plugin&utm_medium=link&utm_campaign=dfrapiaccountpage" target="_blank">' . __('View your Datafeedr account', DFRAPI_DOMAIN) . '</a></p>'; echo '<p><a href="' . dfrapi_user_pages('change') . '?utm_source=plugin&utm_medium=link&utm_campaign=dfrapiaccountpage" target="_blank">' . __('Upgrade your plan', DFRAPI_DOMAIN) . '</a></p>'; }
function dfrapi_email_user_about_usage() { $percentage = dfrapi_get_api_usage_percentage(); $status = get_option('dfrapi_account', array()); $request_count = isset($status['request_count']) ? number_format($status['request_count']) : 0; $remaining_requests = isset($status['max_requests']) ? number_format($status['max_requests'] - $request_count) : 0; $reset_date = ''; if (isset($status['bill_day'])) { $today = date('j'); $num_days = date('t'); if ($status['bill_day'] > $num_days) { $bill_day = $num_days; } else { $bill_day = $status['bill_day']; } if ($bill_day == 0) { $reset_date .= '<em>' . __('Never', DFRAPI_DOMAIN) . '</em>'; } elseif ($today >= $bill_day) { $reset_date .= date('F', strtotime('+1 month')) . ' ' . $bill_day . ', ' . date('Y', strtotime('+1 month')); } else { $reset_date .= date('F') . ' ' . $bill_day . ', ' . date('Y'); } } $default = array('90_percent' => '', '100_percent' => ''); // Don't do anything if less than 90%. if ($percentage < 90) { update_option('dfrapi_usage_notification_tracker', $default); return; } $tracker = get_option('dfrapi_usage_notification_tracker', $default); $params = array(); $params['to'] = get_bloginfo('admin_email'); $params['message'] = "<p>" . __("This is an automated message generated by: ", DFRAPI_DOMAIN) . get_bloginfo('wpurl') . "</p>"; if ($percentage >= 100 && empty($tracker['100_percent'])) { $params['subject'] = get_bloginfo('name') . __(': Datafeedr API Usage (Critical)', DFRAPI_DOMAIN); $params['message'] .= "<p>" . __("You have used <strong>100%</strong> of your allocated Datafeedr API requests for this period. <u>You are no longer able to query the Datafeedr API to get product information.</u>", DFRAPI_DOMAIN) . "</p>"; $params['message'] .= "<p><strong>" . __("What to do next?", DFRAPI_DOMAIN) . "</strong></p>"; $params['message'] .= "<p>" . __("We strongly recommend that you upgrade to prevent your product information from becoming outdated.", DFRAPI_DOMAIN) . "</p>"; $params['message'] .= "<p><a href=\"" . dfrapi_user_pages('change') . "?utm_source=email&utm_medium=link&utm_campaign=upgrade100percentnotice\"><strong>" . __("UPGRADE NOW", DFRAPI_DOMAIN) . "</strong></a></p>"; $params['message'] .= "<p>" . __("Upgrading only takes a minute. You will have <strong>instant access</strong> to more API requests. Any remaining credit for your current plan will be applied to your new plan.", DFRAPI_DOMAIN) . "</p>"; $params['message'] .= "<p>" . __("You are under no obligation to upgrade. You may continue using your current plan for as long as you would like.", DFRAPI_DOMAIN) . "</p>"; $params['message'] .= "<p>" . __("If you have any questions about your account, please ", DFRAPI_DOMAIN); $params['message'] .= "<a href=\"" . DFRAPI_EMAIL_US_URL . "?utm_source=email&utm_medium=link&utm_campaign=upgrade100percentnotice\">" . __("contact us", DFRAPI_DOMAIN) . "</a>.</p>"; $params['message'] .= "<p>" . __("Thanks,<br />Eric & Stefan<br />The Datafeedr Team", DFRAPI_DOMAIN) . "</p>"; $params['message'] .= "<p>"; $params['message'] .= "<a href=\"" . admin_url('admin.php?page=dfrapi_account') . "\">" . __("Account Information", DFRAPI_DOMAIN) . "</a> | "; $params['message'] .= "<a href=\"" . dfrapi_user_pages('change') . "?utm_source=email&utm_medium=link&utm_campaign=upgrade100percentnotice\">" . __("Upgrade Account", DFRAPI_DOMAIN) . "</a>"; $params['message'] .= "</p>"; $tracker['100_percent'] = 1; update_option('dfrapi_usage_notification_tracker', $tracker); add_filter('wp_mail_content_type', 'dfrapi_set_html_content_type'); wp_mail($params['to'], $params['subject'], $params['message']); remove_filter('wp_mail_content_type', 'dfrapi_set_html_content_type'); } elseif ($percentage >= 90 && $percentage < 100 && empty($tracker['90_percent'])) { $params['subject'] = get_bloginfo('name') . __(': Datafeedr API Usage (Warning)', DFRAPI_DOMAIN); $params['message'] .= "<p>" . __("You have used <strong>90%</strong> of your allocated Datafeedr API requests for this period.", DFRAPI_DOMAIN) . "</p>"; $params['message'] .= "<p><strong>" . __("API Usage", DFRAPI_DOMAIN) . "</strong></p>"; $params['message'] .= "<ul>"; $params['message'] .= "<li>" . __("API requests used: ", DFRAPI_DOMAIN) . $request_count . "</li>"; $params['message'] .= "<li>" . __("API requests remaining: ", DFRAPI_DOMAIN) . $remaining_requests . "</li>"; $params['message'] .= "<li>" . __("API requests will reset on: ", DFRAPI_DOMAIN) . $reset_date . "</li>"; $params['message'] .= "</ul>"; $params['message'] .= "<p><strong>" . __("What to do next?", DFRAPI_DOMAIN) . "</strong></p>"; $params['message'] .= "<p>" . __("We recommend that you upgrade to prevent your product information from becoming outdated.", DFRAPI_DOMAIN) . "</p>"; $params['message'] .= "<p><a href=\"" . dfrapi_user_pages('change') . "?utm_source=email&utm_medium=link&utm_campaign=upgrade90percentnotice\"><strong>" . __("UPGRADE NOW", DFRAPI_DOMAIN) . "</strong></a></p>"; $params['message'] .= "<p>" . __("Upgrading only takes a minute. You will have <strong>instant access</strong> to more API requests. Any remaining credit for your current plan will be applied to your new plan.", DFRAPI_DOMAIN) . "</p>"; $params['message'] .= "<p>" . __("You are under no obligation to upgrade. You may continue using your current plan for as long as you would like.", DFRAPI_DOMAIN) . "</p>"; $params['message'] .= "<p>" . __("If you have any questions about your account, please ", DFRAPI_DOMAIN); $params['message'] .= "<a href=\"" . DFRAPI_EMAIL_US_URL . "?utm_source=email&utm_medium=link&utm_campaign=upgrade90percentnotice\">" . __("contact us", DFRAPI_DOMAIN) . "</a>.</p>"; $params['message'] .= "<p>" . __("Thanks,<br />Eric & Stefan<br />The Datafeedr Team", DFRAPI_DOMAIN) . "</p>"; $params['message'] .= "<p>"; $params['message'] .= "<a href=\"" . admin_url('admin.php?page=dfrapi_account') . "\">" . __("Account Information", DFRAPI_DOMAIN) . "</a> | "; $params['message'] .= "<a href=\"" . dfrapi_user_pages('change') . "?utm_source=email&utm_medium=link&utm_campaign=upgrade90percentnotice\">" . __("Upgrade Account", DFRAPI_DOMAIN) . "</a>"; $params['message'] .= "</p>"; $tracker['90_percent'] = 1; update_option('dfrapi_usage_notification_tracker', $tracker); add_filter('wp_mail_content_type', 'dfrapi_set_html_content_type'); wp_mail($params['to'], $params['subject'], $params['message']); remove_filter('wp_mail_content_type', 'dfrapi_set_html_content_type'); } return; }
function admin_notices() { $dfrapi_env = new Dfrapi_Env(); if ($notices = get_option('dfrapi_admin_notices')) { foreach ($notices as $key => $message) { $button = $message['url'] != '' ? dfrapi_fix_button($message['url'], $message['button_text']) : ''; $upgrade_account = $key == 'usage_over_90_percent' ? ' | <a href="' . dfrapi_user_pages('change') . '?utm_source=plugin&utm_medium=link&utm_campaign=upgradenag">' . __('Upgrade', DFRAPI_DOMAIN) . '</a>' : ''; echo '<div class="' . $message['class'] . '">' . $message['message'] . $button . $upgrade_account . '</div>'; } delete_option('dfrapi_admin_notices'); } }