/**
  * Constructor.
  *
  * @since 3.0.0
  *
  * @param string $page
  */
 public function __construct($page = 'settings')
 {
     $this->page = $page;
     $settings_pages = !is_null(\SimpleCalendar\plugin()->objects) ? simcal_get_admin_pages() : '';
     $settings_page_tabs = array();
     $tabs = isset($settings_pages[$page]) ? $settings_pages[$page] : false;
     if ($tabs && is_array($tabs)) {
         foreach ($tabs as $tab) {
             $settings_page = simcal_get_admin_page($tab);
             if ($settings_page instanceof Admin_Page) {
                 $settings_page_tabs[$settings_page->id] = $settings_page;
             }
         }
         $this->settings = $settings_page_tabs;
     }
     // The first tab is the default tab when opening a page.
     $this->tab = isset($tabs[0]) ? $tabs[0] : '';
     do_action('simcal_admin_pages', $page);
 }
/**
 * Get a field.
 *
 * @since  3.0.0
 *
 * @param  array  $args
 * @param  string $name
 *
 * @return null|\SimpleCalendar\Abstracts\Field
 */
function simcal_get_field($args, $name = '')
{
    $objects = \SimpleCalendar\plugin()->objects;
    return $objects instanceof \SimpleCalendar\Objects ? $objects->get_field($args, $name) : null;
}
/**
 * Common scripts variables.
 *
 * Variables to print in scripts localization
 *
 * @since  3.0.0
 *
 * @return array
 */
function simcal_common_scripts_variables()
{
    $vars = array('ajax_url' => \SimpleCalendar\plugin()->ajax_url(), 'nonce' => wp_create_nonce('simcal'), 'locale' => \SimpleCalendar\plugin()->locale, 'text_dir' => is_rtl() ? 'rtl' : 'ltr', 'months' => array('full' => simcal_get_calendar_names_i18n('month', 'full'), 'short' => simcal_get_calendar_names_i18n('month', 'short')), 'days' => array('full' => simcal_get_calendar_names_i18n('day', 'full'), 'short' => simcal_get_calendar_names_i18n('day', 'short')), 'meridiem' => simcal_get_calendar_names_i18n('meridiem'));
    return array_merge($vars, apply_filters('simcal_common_scripts_variables', array()));
}
Exemplo n.º 4
0
    /**
     * Admin footer text filter callback.
     *
     * Change this plugin screens admin footer text.
     *
     * @since  3.0.0
     *
     * @param  $footer_text
     *
     * @return string|void
     */
    public function admin_footer_text($footer_text)
    {
        // Check to make sure we're on a SimpleCal admin page
        $screen = simcal_is_admin_screen();
        if ($screen !== false) {
            if ('calendar' == $screen) {
                // Add Drip promo signup form (@see Newsletter meta box).
                $drip_form_id = '9817628';
                ?>
				<form id="simcal-drip-form"
				      method="post"
				      target="_blank"
				      action="https://www.getdrip.com/forms/<?php 
                echo $drip_form_id;
                ?>
/submissions/"
				      data-drip-embedded-form="<?php 
                echo $drip_form_id;
                ?>
">
					<input type="hidden"
					       id="simcal-drip-real-field-first_name"
					       name="fields[first_name]"
					       value="" />
					<input type="hidden"
					       id="simcal-drip-real-field-email"
					       name="fields[email]"
					       value="" />
					<input type="submit"
					       class="hidden"/>
				</form>
				<?php 
            }
            // Change the footer text
            if (!get_option('simple-calendar_admin_footer_text_rated')) {
                $footer_text = sprintf(__('If you like <strong>Simple Calendar</strong> please leave us a %s&#9733;&#9733;&#9733;&#9733;&#9733; rating on WordPress.org%s. A huge thank you in advance!', 'google-calendar-events'), '<a href="https://wordpress.org/support/view/plugin-reviews/google-calendar-events?filter=5#postform" target="_blank" class="simcal-rating-link" data-rated="' . esc_attr__('Thanks :)', 'google-calendar-events') . '">', '</a>');
                $footer_text .= '<script type="text/javascript">';
                $footer_text .= "jQuery( 'a.simcal-rating-link' ).click( function() {\n\t\t\t\t\t\tjQuery.post( '" . \SimpleCalendar\plugin()->ajax_url() . "', { action: 'simcal_rated' } );\n\t\t\t\t\t\tjQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );\n\t\t\t\t\t});";
                $footer_text .= '</script>';
            } else {
                $footer_text = __('Thank you for using Simple Calendar!', 'google-calendar-events');
            }
        }
        return $footer_text;
    }