/**
  * Output page markup.
  *
  * @since 3.0.0
  */
 public function html()
 {
     // @todo pull data from simplecalendar.io to showcase add-ons
     $js_redirect = '<script type="text/javascript">';
     $js_redirect .= 'window.location = "' . simcal_ga_campaign_url(simcal_get_url('add-ons'), 'core-plugin', 'plugin-submenu-link', true) . '"';
     $js_redirect .= '</script>';
     echo $js_redirect;
 }
/**
 * Newsletter signup form.
 *
 * @since  3.0.0
 *
 * @return void
 */
function simcal_newsletter_signup()
{
    if ($screen = simcal_is_admin_screen()) {
        global $current_user;
        wp_get_current_user();
        $name = $current_user->user_firstname ? $current_user->user_firstname : '';
        ?>
		<div id="simcal-drip" class="<?php 
        echo $screen;
        ?>
">
			<div class="signup">
				<p>
					<?php 
        _e("Enter your name and email and we'll send you a coupon code for 20% off our Google Calendar Pro add-on.", 'google-calendar-events');
        ?>
				</p>

				<p>
					<label for="simcal-drip-field-email"><?php 
        _e('Your Email', 'google-calendar-events');
        ?>
</label><br />
					<input type="email"
					       id="simcal-drip-field-email"
					       name="fields[email]"
					       value="<?php 
        echo $current_user->user_email;
        ?>
" />
				</p>

				<p>
					<label for="simcal-drip-field-first_name"><?php 
        _e('First Name', 'google-calendar-events');
        ?>
</label><br />
					<input type="text"
					       id="simcal-drip-field-first_name"
					       name="fields[first_name]"
					       value="<?php 
        echo $name;
        ?>
" />
				</p>
				<p class="textright">
					<a href="#"
					   id="simcal-drip-signup"
					   class="button button-primary"><?php 
        _e('Send me the coupon', 'google-calendar-events');
        ?>
</a>
				</p>
				<div class="textright">
					<a href="<?php 
        echo simcal_ga_campaign_url(simcal_get_url('gcal-pro'), 'core-plugin', 'sidebar-link');
        ?>
"
					   target="_blank"><?php 
        _e('Just take me to GCal Pro', 'google-calendar-events');
        ?>
</a>
				</div>
			</div>
			<div class="thank-you" style="display: none;">
				<?php 
        _e('Thank you!', 'google-calendar-events');
        ?>
			</div>
			<div class="clear">
			</div>
		</div>
		<?php 
    }
}
 /**
  * Activate add-on license.
  *
  * This code is run only when an add-on requiring a license is installed and active.
  *
  * @since 3.0.0
  */
 public function manage_add_on_license()
 {
     $addon = isset($_POST['add_on']) ? sanitize_key($_POST['add_on']) : false;
     $action = isset($_POST['license_action']) ? esc_attr($_POST['license_action']) : false;
     $key = isset($_POST['license_key']) ? esc_attr($_POST['license_key']) : '';
     $nonce = isset($_POST['nonce']) ? esc_attr($_POST['nonce']) : '';
     // Verify that there are valid variables to process.
     if (false === $addon || !in_array($action, array('activate_license', 'deactivate_license'))) {
         wp_send_json_error(__('Add-on unspecified or invalid action.', 'google-calendar-events'));
     }
     // Verify this request comes from the add-ons licenses activation settings page.
     if (!wp_verify_nonce($nonce, 'simcal_license_manager')) {
         wp_send_json_error(sprintf(__('An error occurred: %s', 'google-calendar-events'), 'Nonce verification failed.'));
     }
     // Removes the prefix and converts simcal_{id_no} to {id_no}.
     $id = intval(substr($addon, 7));
     // Data to send in API request.
     $api_request = array('edd_action' => $action, 'license' => $key, 'item_id' => urlencode($id), 'url' => home_url());
     // Call the custom API.
     $response = wp_remote_post(defined('SIMPLE_CALENDAR_STORE_URL') ? SIMPLE_CALENDAR_STORE_URL : simcal_get_url('home'), array('timeout' => 15, 'sslverify' => false, 'body' => $api_request));
     // Update license in db.
     $keys = get_option('simple-calendar_settings_licenses', array());
     $new_keys = array_merge((array) $keys, array('keys' => array($addon => $key)));
     update_option('simple-calendar_settings_licenses', $new_keys);
     // Make sure there is a response.
     if (is_wp_error($response)) {
         wp_send_json_error(sprintf(__('There was an error processing your request: %s', 'google-calendar-events'), $response->get_error_message()));
     }
     // Decode the license data and save.
     $license_data = json_decode(wp_remote_retrieve_body($response));
     $status = simcal_get_license_status();
     if ('deactivated' == $license_data->license) {
         unset($status[$addon]);
         update_option('simple-calendar_licenses_status', $status);
         wp_send_json_success($license_data->license);
     } elseif (in_array($license_data->license, array('valid', 'invalid'))) {
         $status[$addon] = $license_data->license;
         update_option('simple-calendar_licenses_status', $status);
         $message = 'valid' == $license_data->license ? 'valid' : __('License key is invalid.', 'google-calendar-events');
         wp_send_json_success($message);
     } else {
         wp_send_json_error('');
     }
 }
 /**
  * Test a connection to Google Calendar API.
  *
  * @since  3.0.0
  *
  * @param  string $google_calendar_id
  *
  * @return true|string
  */
 public function test_api_key_connection($google_calendar_id)
 {
     global $post;
     $post_id = isset($post->ID) ? $post->ID : 0;
     $feed = null;
     if ($feed_type = wp_get_object_terms($post_id, 'calendar_feed')) {
         $feed = sanitize_title(current($feed_type)->name);
     }
     $message = '';
     $error = '';
     $has_errors = false;
     $message .= '<p class="description">' . sprintf(__('Step 1: Set the Google Calendar you want to use as <strong>"public."</strong> <a href="%1s" target="_blank">Detailed instructions</a>', 'google-calendar-events') . '<br />' . __('Step 2: Copy and paste your Google Calendar ID here. <a href="%2s" target="_blank">Detailed instructions</a>', 'google-calendar-events'), simcal_ga_campaign_url(simcal_get_url('docs') . '/make-google-calendar-public/', 'core-plugin', 'settings-link'), simcal_ga_campaign_url(simcal_get_url('docs') . '/find-google-calendar-id/', 'core-plugin', 'settings-link')) . '</p>';
     if ($post_id > 0 && !is_null($feed) && !empty($this->feed->type)) {
         $no_key_notice = new Notice(array('id' => array('calendar_' . $post_id => 'google-no-api-key'), 'type' => 'error', 'screen' => 'calendar', 'post' => $post_id, 'dismissable' => false, 'content' => '<p>' . '<i class="simcal-icon-warning"></i> ' . sprintf(__('Your Google Calendar events will not show up until you <a href="%s">create and save a Google API key</a>.', 'google-calendar-events'), admin_url('edit.php?post_type=calendar&page=simple-calendar_settings&tab=feeds')) . '</p>'));
         if (empty($this->google_api_key) && $feed == $this->feed->type) {
             $has_errors = true;
             $no_key_notice->add();
         } else {
             $no_key_notice->remove();
             try {
                 $this->feed->make_request($google_calendar_id);
             } catch (\Exception $e) {
                 $error = $e->getMessage();
                 $message = !empty($error) ? '<blockquote>' . $error . '</blockquote>' : '';
             }
             $error_notice = new Notice(array('id' => array('calendar_' . $post_id => 'google-error-response'), 'type' => 'error', 'screen' => 'calendar', 'post' => $post_id, 'dismissable' => false, 'content' => '<p>' . '<i class="simcal-icon-warning"></i> ' . __('While trying to retrieve events, Google returned an error:', 'google-calendar-events') . '<br>' . $message . '<br>' . __('Please ensure that both your Google Calendar ID and API Key are valid and that the Google Calendar you want to display is public.', 'google-calendar-events') . '</p>'));
             if (!empty($error) && $feed == $this->feed->type) {
                 $error_notice->add();
                 $has_errors = true;
             } else {
                 $error_notice->remove();
                 $has_errors = false;
             }
         }
     }
     return $message;
 }
 /**
  * Output the calendar markup.
  *
  * @since 3.0.0
  *
  * @param string $view The calendar view to display.
  */
 public function html($view = '')
 {
     $view = empty($view) ? $this->view : $this->get_view($view);
     if ($view instanceof Calendar_View) {
         if (!empty($this->errors)) {
             if (current_user_can('manage_options')) {
                 echo '<pre><code>';
                 foreach ($this->errors as $error) {
                     echo $error;
                 }
                 echo '</code></pre>';
             }
         } else {
             // Get a CSS class from the class name of the calendar view (minus namespace part).
             $view_name = implode('-', array_map('lcfirst', explode('_', strtolower(get_class($view)))));
             $view_class = substr($view_name, strrpos($view_name, '\\') + 1);
             $calendar_class = trim(implode(' simcal-', apply_filters('simcal_calendar_class', array('simcal-calendar', $this->type, $view_class), $this->id)));
             echo '<div class="' . $calendar_class . '" ' . 'data-calendar-id="' . $this->id . '" ' . 'data-timezone="' . $this->timezone . '" ' . 'data-offset="' . $this->offset . '" ' . 'data-week-start="' . $this->week_starts . '" ' . 'data-calendar-start="' . $this->start . '" ' . 'data-calendar-end="' . $this->end . '" ' . 'data-events-first="' . $this->earliest_event . '" ' . 'data-events-last="' . $this->latest_event . '"' . '>';
             date_default_timezone_set($this->timezone);
             do_action('simcal_calendar_html_before', $this->id);
             $view->html();
             do_action('simcal_calendar_html_after', $this->id);
             date_default_timezone_set($this->site_timezone);
             $settings = get_option('simple-calendar_settings_calendars');
             $poweredby = isset($settings['poweredby']['opt_in']) ? $settings['poweredby']['opt_in'] : '';
             if ('yes' == $poweredby) {
                 $align = is_rtl() ? 'left' : 'right';
                 echo '<small class="simcal-powered simcal-align-' . $align . '">' . sprintf(__('Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events'), simcal_get_url('home')) . '</small>';
             }
             echo '</div>';
         }
     }
 }
    /**
     * Output the credits screen.
     *
     * @since 3.0.0
     */
    public function credits_screen()
    {
        ?>
		<div id="simcal-welcome">
			<div class="wrap about-wrap credits-wrap">
				<?php 
        $this->intro();
        ?>
				<p class="about-description">
					<?php 
        printf(__("Simple Calendar is created by a worldwide team of developers. If you'd like to contribute please visit our <a href='%s' target='_blank'>GitHub repo</a>.", 'google-calendar-events'), simcal_get_url('github'));
        ?>
				</p>
				<?php 
        echo $this->contributors();
        ?>
			</div>
		</div>
		<?php 
    }
Example #7
0
 /**
  * Links in plugin meta in plugins page.
  *
  * @since  3.0.0
  *
  * @param  array  $meta_links
  * @param  string $file
  *
  * @return array
  */
 public static function plugin_row_meta($meta_links, $file)
 {
     if (self::$plugin == $file) {
         $links = array();
         $links['github'] = '<a href="' . simcal_get_url('github') . '" target="_blank" >GitHub</a>';
         $links['documentation'] = '<a href="' . simcal_ga_campaign_url(simcal_get_url('docs'), 'core-plugin', 'plugin-listing') . '" target="_blank" >' . __('Documentation', 'google-calendar-events') . '</a>';
         $links['support'] = '<a href="' . simcal_get_url('support') . '" target="_blank" >' . __('Support', 'google-calendar-events') . '</a>';
         $links['add-ons'] = '<a href="' . simcal_ga_campaign_url(simcal_get_url('add-ons'), 'core-plugin', 'plugin-listing') . '" target="_blank" >' . __('Add-ons', 'google-calendar-events') . '</a>';
         return apply_filters('simcal_plugin_action_links', array_merge($meta_links, $links));
     }
     return $meta_links;
 }
Example #8
0
/**
 * Upgrade to Premium Add-ons HTML.
 *
 * @since  3.1.6
 *
 * @return void
 */
function simcal_upgrade_to_premium()
{
    if ($screen = simcal_is_admin_screen()) {
        ?>
		<div class="main">
			<p class="heading centered">
				<?php 
        _e('Some of the features included with our premium add-ons', 'google-calendar-events');
        ?>
			</p>

			<ul>
				<li><div class="dashicons dashicons-yes"></div> <?php 
        _e('Display color coded events', 'google-calendar-events');
        ?>
</li>
				<li><div class="dashicons dashicons-yes"></div> <?php 
        _e('Show week & day views', 'google-calendar-events');
        ?>
</li>
				<li><div class="dashicons dashicons-yes"></div> <?php 
        _e('Fast view switching', 'google-calendar-events');
        ?>
</li>
				<li><div class="dashicons dashicons-yes"></div> <?php 
        _e('Event titles & start times in grid', 'google-calendar-events');
        ?>
</li>
				<li><div class="dashicons dashicons-yes"></div> <?php 
        _e('Limit event display times', 'google-calendar-events');
        ?>
</li>
				<li><div class="dashicons dashicons-yes"></div> <?php 
        _e('Display private calendar events', 'google-calendar-events');
        ?>
</li>
				<li><div class="dashicons dashicons-yes"></div> <?php 
        _e('Show attendees & RSVP status', 'google-calendar-events');
        ?>
</li>
				<li><div class="dashicons dashicons-yes"></div> <?php 
        _e('Display attachments', 'google-calendar-events');
        ?>
</li>
				<li><div class="dashicons dashicons-yes"></div> <?php 
        _e('Priority email support', 'google-calendar-events');
        ?>
</li>
			</ul>

			<div class="centered">
				<a href="<?php 
        echo simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'sidebar-link');
        ?>
"
				   class="button-primary button-large" target="_blank">
					<?php 
        _e('Upgrade to Premium Now', 'google-calendar-events');
        ?>
</a>
			</div>
		</div>
		<?php 
    }
}