コード例 #1
0
ファイル: em-install.php プロジェクト: hypenotic/slowfood
function em_install()
{
    global $wp_rewrite;
    $wp_rewrite->flush_rules();
    $old_version = get_option('dbem_version');
    //Won't upgrade 2 anymore, let 3 do that and we worry about 3.
    if ($old_version != '' && $old_version < 3.096) {
        function em_update_required_notification()
        {
            global $EM_Booking;
            ?>
<div class="error"><p><strong>Events Manager upgrade not complete, please upgrade to the version 3.0.96 or higher first from <a href="http://wordpress.org/extend/plugins/events-manager/download/">here</a> first before upgrading to this version. <a href="http://wp-events-plugin.com/news/upgrade-issues-screencast-walkthrough/">We made a screencast</a> to help you out.</strong></p></div><?php 
        }
        add_action('admin_notices', 'em_update_required_notification');
        return;
    }
    if (EM_VERSION > $old_version || $old_version == '') {
        // Creates the events table if necessary
        em_create_events_table();
        em_create_events_meta_table();
        em_create_locations_table();
        em_create_bookings_table();
        em_create_categories_table();
        em_create_tickets_table();
        em_create_tickets_bookings_table();
        em_set_capabilities();
        em_add_options();
        //New install, or Migrate?
        if ($old_version < 4 && !empty($old_version)) {
            em_migrate_v3();
        } elseif (empty($old_version)) {
            update_option('dbem_hello_to_user', 1);
        }
        //Upate Version
        update_option('dbem_version', EM_VERSION);
        // wp-content must be chmodded 777. Maybe just wp-content.
        if (!file_exists(EM_IMAGE_UPLOAD_DIR)) {
            mkdir(EM_IMAGE_UPLOAD_DIR, 0777);
            //do we need to 777 it? it'll be owner apache anyway, like normal uploads
            if (EM_IMAGE_DS == '/') {
                mkdir(EM_IMAGE_UPLOAD_DIR . "events/", 0777);
                //do we need to 777 it? it'll be owner apache anyway, like normal uploads
                mkdir(EM_IMAGE_UPLOAD_DIR . "locations/", 0777);
                //do we need to 777 it? it'll be owner apache anyway, like normal uploads
                mkdir(EM_IMAGE_UPLOAD_DIR . "categories/", 0777);
                //do we need to 777 it? it'll be owner apache anyway, like normal uploads
            }
        }
        em_create_events_page();
    }
}
コード例 #2
0
ファイル: em-install.php プロジェクト: hypenotic/slowfood
function em_install()
{
    $old_version = get_option('dbem_version');
    //Won't upgrade 2 anymore, let 3 do that and we worry about 3.
    if ($old_version != '' && $old_version < 3.096) {
        die('Cannot proceed with installation, please upgrade to the version 3.0.96 or higher from <a href="http://wordpress.org/extend/plugins/events-manager/download/">here</a> first before upgrading to this version.');
    }
    if (EM_VERSION > $old_version || $old_version == '') {
        // Creates the events table if necessary
        em_create_events_table();
        em_create_events_meta_table();
        em_create_locations_table();
        em_create_bookings_table();
        em_create_categories_table();
        em_create_tickets_table();
        em_create_tickets_bookings_table();
        em_set_capabilities();
        em_add_options();
        //Migrate?
        if ($old_version < 4 && $old_version != '') {
            em_migrate_v3();
        } else {
            if ($old_version < 4.002 && $old_version > 4) {
                add_option('dbem_notice_rc_reimport', 1);
            }
        }
        //Upate Version
        update_option('dbem_version', EM_VERSION);
        // wp-content must be chmodded 777. Maybe just wp-content.
        if (!file_exists(EM_IMAGE_UPLOAD_DIR)) {
            mkdir(EM_IMAGE_UPLOAD_DIR, 0777);
            //do we need to 777 it? it'll be owner apache anyway, like normal uploads
            if (EM_IMAGE_DS == '/') {
                mkdir(EM_IMAGE_UPLOAD_DIR . "events/", 0777);
                //do we need to 777 it? it'll be owner apache anyway, like normal uploads
                mkdir(EM_IMAGE_UPLOAD_DIR . "locations/", 0777);
                //do we need to 777 it? it'll be owner apache anyway, like normal uploads
                mkdir(EM_IMAGE_UPLOAD_DIR . "categories/", 0777);
                //do we need to 777 it? it'll be owner apache anyway, like normal uploads
            }
        }
        em_create_events_page();
    }
}
コード例 #3
0
ファイル: em-admin.php プロジェクト: hypenotic/slowfood
/**
 * Generate warnings and notices in the admin area
 */
function em_admin_warnings()
{
    //If we're editing the events page show hello to new user
    $events_page_id = get_option('dbem_events_page');
    $dismiss_link_joiner = count($_GET) > 0 ? '&amp;' : '?';
    if (current_user_can('activate_plugins')) {
        //New User Intro
        if (isset($_GET['disable_hello_to_user']) && $_GET['disable_hello_to_user'] == 'true') {
            // Disable Hello to new user if requested
            update_option('dbem_hello_to_user', 0);
        } elseif (get_option('dbem_hello_to_user') == 1 && !empty($_GET['page']) && $_GET['page'] == 'events-manager-events') {
            $current_user = wp_get_current_user();
            //FIXME update welcome msg with good links
            $advice = sprintf(__("<p>Hey, <strong>%s</strong>, welcome to <strong>Events Manager</strong>! We hope you like it around here.</p> \n\t\t\t<p>Now it's time to insert events lists through  <a href='%s' title='Widgets page'>widgets</a>, <a href='%s' title='Template tags documentation'>template tags</a> or <a href='%s' title='Shortcodes documentation'>shortcodes</a>.</p>\n\t\t\t<p>By the way, have you taken a look at the <a href='%s' title='Change settings'>Settings page</a>? That's where you customize the way events and locations are displayed.</p>\n\t\t\t<p>What? Tired of seeing this advice? I hear you, <a href='%s' title='Don't show this advice again'>click here</a> and you won't see this again!</p>", 'dbem'), $current_user->display_name, get_bloginfo('url') . '/wp-admin/widgets.php', 'http://wp-events-plugin.com/documentation/template-tags/', 'http://wp-events-plugin.com/documentation/shortcodes/', get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager-options', get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager&disable_hello_to_user=true');
            ?>
			<div id="message" class="updated">
				<?php 
            echo $advice;
            ?>
			</div>
			<?php 
        }
        //Image upload folders
        if (is_admin() && EM_IMAGE_DS == '/') {
            $errs = array();
            if (is_writable(EM_IMAGE_UPLOAD_DIR) || @mkdir(EM_IMAGE_UPLOAD_DIR, 0777)) {
                if (!is_writable(EM_IMAGE_UPLOAD_DIR . '/events/') && !@mkdir(EM_IMAGE_UPLOAD_DIR . "events/", 0777)) {
                    $errs[] = 'events';
                }
                if (!is_writable(EM_IMAGE_UPLOAD_DIR . '/locations/') && !@mkdir(EM_IMAGE_UPLOAD_DIR . "locations/", 0777)) {
                    $errs[] = 'locations';
                }
                if (!is_writable(EM_IMAGE_UPLOAD_DIR . '/categories/') && !@mkdir(EM_IMAGE_UPLOAD_DIR . "categories/", 0777)) {
                    $errs[] = 'categories';
                }
            } elseif (!is_writable(EM_IMAGE_UPLOAD_DIR)) {
                $errs = array('events', 'categories', 'locations');
            }
            if (count($errs) > 0) {
                ?>
				<div class="updated">
					<p><?php 
                echo sprintf(__('The upload directory ' . EM_IMAGE_UPLOAD_DIR . ' is must be present with these writeable folders: %s. Please create these folders with the same write permissions you use for your normal wordpress image upload folders.', 'dbem'), implode(', ', $errs));
                ?>
</p>
				</div>
				<?php 
            }
        }
        //If events page couldn't be created
        if (!empty($_GET['em_dismiss_admin_notice'])) {
            delete_option('dbem_admin_notice_' . $_GET['em_dismiss_admin_notice']);
        } else {
            if (get_option('dbem_admin_notice_3.0.91')) {
                ?>
				<div class="updated">
					<p><?php 
                echo sprintf(__('<strong>Events Manager has some new features!</strong><ul><li>Bookings can now be approved before they count towards your event\'s space allocations.</li><li>Events now have owners, and you can restrict users so they can only manage events/locations/categories they create.<br/><br/>These new permissions are enabled by default, but since you upgraded it has been disabled to maintain the previous plugin behaviour. You can re-enable it from the <a href="%s">settings page</a>. <a href="%s">Dismiss</a>', 'dbem'), get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'] . $dismiss_link_joiner . 'em_dismiss_admin_notice=3.0.91');
                ?>
</p>
				</div>
				<?php 
            }
        }
        //If events page couldn't be created
        if (!empty($_GET['em_dismiss_events_page'])) {
            update_option('dbem_dismiss_events_page', 1);
        } else {
            if (!get_page($events_page_id) && !get_option('dbem_dismiss_events_page')) {
                ?>
				<div id="em_page_error" class="updated">
					<p><?php 
                echo sprintf(__('Uh Oh! For some reason wordpress could not create an events page for you (or you just deleted it). Not to worry though, all you have to do is create an empty page, name it whatever you want, and select it as your events page in your <a href="%s">settings page</a>. Sorry for the extra step! If you know what you are doing, you may have done this on purpose, if so <a href="%s">ignore this message</a>', 'dbem'), get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'] . $dismiss_link_joiner . 'em_dismiss_events_page=1');
                ?>
</p>
				</div>
				<?php 
            }
        }
        //If events page couldn't be created
        if (!empty($_GET['em_dismiss_notice_migrate_v3'])) {
            delete_option('em_notice_migrate_v3');
        } else {
            if (get_option('em_notice_migrate_v3')) {
                ?>
				<div id="em_page_error" class="updated">
					<p><?php 
                echo sprintf(__('A <strong>LOT</strong> has changed since Events Manager 3. We recommend you take a look at the <a href="%s">settings page</a> for new features and upgrade instructions, and you may particualarly be interested in modifying permissions. <a href="%s">Dismiss</a>'), 'admin.php?page=events-manager-options', em_add_get_params($_SERVER['REQUEST_URI'], array('em_dismiss_notice_migrate_v3' => 1)));
                ?>
</p>
				</div>
				<?php 
            }
        }
        //Fixing the RC2 fiasco
        if (!empty($_GET['em_dismiss_notice_rc_reimport'])) {
            delete_option('dbem_notice_rc_reimport');
        } else {
            if (get_option('dbem_notice_rc_reimport')) {
                ?>
				<div id="em_page_error" class="updated">
					<p><?php 
                echo sprintf(__('If you upgraded from 3.x to the RC2 and the update did not go so well, <a href="%s">try reimporting old settings</a>. Warning! Re-importing will rename all event slugs, re-import your old category settings from events, and recreate all tickets, so changes to these areas will be lost. <a href="%s">Dismiss</a>'), 'admin.php?page=events-manager-options&action=em_rc_reimport&_wpnonce=' . wp_create_nonce('em_rc_reimport'), em_add_get_params($_SERVER['REQUEST_URI'], array('em_dismiss_notice_rc_reimport' => 1)));
                ?>
</p>
				</div>
				<?php 
            }
        }
        if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'em_rc_reimport' && wp_verify_nonce($_REQUEST['_wpnonce'], 'em_rc_reimport')) {
            require_once dirname(__FILE__) . '/../em-install.php';
            em_migrate_v3();
            ?>
			<div id="em_page_error" class="updated">
				<p>Reimporting old settings was successful. Click the dismiss button on the other notification if after checking things are now working.</p>
			</div>
			<?php 
        }
    }
    //Warn about EM page edit
    if (preg_match('/(post|page).php/', $_SERVER['SCRIPT_NAME']) && isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['post']) && $_GET['post'] == "{$events_page_id}") {
        $message = sprintf(__("This page corresponds to <strong>Events Manager</strong> events page. Its content will be overriden by Events Manager, although if you include the word CONTENTS (exactly in capitals) and surround it with other text, only CONTENTS will be overwritten. If you want to change the way your events look, go to the <a href='%s'>settings</a> page. ", 'dbem'), 'admin.php?page=events-manager-options');
        $notice = "<div class='error'><p>{$message}</p></div>";
        echo $notice;
    }
}
コード例 #4
0
ファイル: em-admin.php プロジェクト: hypenotic/slowfood
/**
 * Generate warnings and notices in the admin area
 */
function em_admin_warnings()
{
    //If we're editing the events page show hello to new user
    $events_page_id = get_option('dbem_events_page');
    $dismiss_link_joiner = count($_GET) > 0 ? '&amp;' : '?';
    if (current_user_can('activate_plugins')) {
        //New User Intro
        if (isset($_GET['disable_hello_to_user']) && $_GET['disable_hello_to_user'] == 'true') {
            // Disable Hello to new user if requested
            update_option('dbem_hello_to_user', 0);
        } elseif (get_option('dbem_hello_to_user')) {
            //FIXME update welcome msg with good links
            $advice = sprintf(__("<p>Events Manager is ready to go! It is highly recommended you read the <a href='%s'>Getting Started</a> guide on our site, as well as checking out the <a href='%s'>Settings Page</a>. <a href='%s' title='Don't show this advice again'>Dismiss</a></p>", 'dbem'), 'http://wp-events-plugin.com/documentation/getting-started/?utm_source=em&utm_medium=plugin&utm_content=installationlink&utm_campaign=plugin_links', get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'] . $dismiss_link_joiner . 'disable_hello_to_user=true');
            ?>
			<div id="message" class="updated">
				<?php 
            echo $advice;
            ?>
			</div>
			<?php 
        }
        //Image upload folders
        if (is_admin() && EM_IMAGE_DS == '/') {
            $errs = array();
            if (is_writable(EM_IMAGE_UPLOAD_DIR) || @mkdir(EM_IMAGE_UPLOAD_DIR, 0777)) {
                if (!is_writable(EM_IMAGE_UPLOAD_DIR . '/events/') && !@mkdir(EM_IMAGE_UPLOAD_DIR . "events/", 0777)) {
                    $errs[] = 'events';
                }
                if (!is_writable(EM_IMAGE_UPLOAD_DIR . '/locations/') && !@mkdir(EM_IMAGE_UPLOAD_DIR . "locations/", 0777)) {
                    $errs[] = 'locations';
                }
                if (!is_writable(EM_IMAGE_UPLOAD_DIR . '/categories/') && !@mkdir(EM_IMAGE_UPLOAD_DIR . "categories/", 0777)) {
                    $errs[] = 'categories';
                }
            } elseif (!is_writable(EM_IMAGE_UPLOAD_DIR)) {
                $errs = array('events', 'categories', 'locations');
            }
            if (count($errs) > 0) {
                ?>
				<div class="updated">
					<p><?php 
                echo sprintf(__('The upload directory ' . EM_IMAGE_UPLOAD_DIR . ' is must be present with these writeable folders: %s. Please create these folders with the same write permissions you use for your normal wordpress image upload folders.', 'dbem'), implode(', ', $errs));
                ?>
</p>
				</div>
				<?php 
            }
        }
        //If events page couldn't be created
        if (!empty($_GET['em_dismiss_admin_notice'])) {
            delete_option('dbem_admin_notice_' . $_GET['em_dismiss_admin_notice']);
        } else {
            if (get_option('dbem_admin_notice_3.0.91')) {
                ?>
				<div class="updated">
					<p><?php 
                echo sprintf(__('<strong>Events Manager has some new features!</strong><ul><li>Bookings can now be approved before they count towards your event\'s space allocations.</li><li>Events now have owners, and you can restrict users so they can only manage events/locations/categories they create.<br/><br/>These new permissions are enabled by default, but since you upgraded it has been disabled to maintain the previous plugin behaviour. You can re-enable it from the <a href="%s">settings page</a>. <a href="%s">Dismiss</a>', 'dbem'), get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'] . $dismiss_link_joiner . 'em_dismiss_admin_notice=3.0.91');
                ?>
</p>
				</div>
				<?php 
            }
        }
        //If events page couldn't be created
        if (!empty($_GET['em_dismiss_events_page'])) {
            update_option('dbem_dismiss_events_page', 1);
        } else {
            if (!get_page($events_page_id) && !get_option('dbem_dismiss_events_page')) {
                ?>
				<div id="em_page_error" class="updated">
					<p><?php 
                echo sprintf(__('Uh Oh! For some reason wordpress could not create an events page for you (or you just deleted it). Not to worry though, all you have to do is create an empty page, name it whatever you want, and select it as your events page in your <a href="%s">settings page</a>. Sorry for the extra step! If you know what you are doing, you may have done this on purpose, if so <a href="%s">ignore this message</a>', 'dbem'), get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'] . $dismiss_link_joiner . 'em_dismiss_events_page=1');
                ?>
</p>
				</div>
				<?php 
            }
        }
        //If events page couldn't be created
        if (!empty($_GET['em_dismiss_notice_migrate_v3'])) {
            delete_option('em_notice_migrate_v3');
        } else {
            if (get_option('em_notice_migrate_v3')) {
                ?>
				<div id="em_page_error" class="updated">
					<p><?php 
                echo sprintf(__('A <strong>LOT</strong> has changed since Events Manager 3. We recommend you take a look at the <a href="%s">settings page</a> for new features and upgrade instructions, and you may particualarly be interested in modifying permissions. <a href="%s">Dismiss</a>'), 'admin.php?page=events-manager-options', em_add_get_params($_SERVER['REQUEST_URI'], array('em_dismiss_notice_migrate_v3' => 1)));
                ?>
</p>
				</div>
				<?php 
            }
        }
        if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'em_rc_reimport' && wp_verify_nonce($_REQUEST['_wpnonce'], 'em_rc_reimport')) {
            require_once dirname(__FILE__) . '/../em-install.php';
            em_migrate_v3();
            ?>
			<div id="em_page_error" class="updated">
				<p>Reimporting old settings was successful. Click the dismiss button on the other notification if after checking things are now working.</p>
			</div>
			<?php 
        }
        if (defined('EMP_VERSION') && EMP_VERSION < EM_PRO_MIN_VERSION) {
            ?>
			<div id="em_page_error" class="updated">
				<p>There is a newer version of Events Manager Pro which is required for this current version of Events Manager. Please go to the plugin website and download the latest update.</p>
			</div>
			<?php 
        }
    }
    //Warn about EM page edit
    if (preg_match('/(post|page).php/', $_SERVER['SCRIPT_NAME']) && isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['post']) && $_GET['post'] == "{$events_page_id}") {
        $message = sprintf(__("This page corresponds to <strong>Events Manager</strong> events page. Its content will be overriden by Events Manager, although if you include the word CONTENTS (exactly in capitals) and surround it with other text, only CONTENTS will be overwritten. If you want to change the way your events look, go to the <a href='%s'>settings</a> page. ", 'dbem'), 'admin.php?page=events-manager-options');
        $notice = "<div class='error'><p>{$message}</p></div>";
        echo $notice;
    }
}