Example #1
0
/**
 * Upgrade routine
 *
 * @package WP Idea Stream
 * @subpackage core/upgrade
 *
 * @since 2.0.0
 *
 * @uses  wp_idea_stream_db_version() to get DB version
 * @uses  wp_idea_stream_add_options() to add options based on legacy ones
 * @uses  update_option() to update db version
 * @uses  wp_idea_stream_get_version() to get current plugin's version
 * @uses  wp_idea_stream_delete_rewrite_rules() to reset rewrites
 */
function wp_idea_stream_upgrade()
{
    $db_version = wp_idea_stream_db_version();
    if (!empty($db_version)) {
        if ((int) $db_version < 2) {
            // Filter default options to take in account legacy options
            add_filter('wp_idea_stream_get_default_options', 'wp_idea_stream_merge_legacy_options', 10, 1);
            wp_idea_stream_add_options();
        } elseif (version_compare($db_version, '2.3.0', '<')) {
            wp_idea_stream_upgrade_to_2_3();
        }
        // It's a new install
    } else {
        wp_idea_stream_install();
    }
    update_option('_ideastream_version', wp_idea_stream_get_version());
    // Force a rewrite rules reset
    wp_idea_stream_delete_rewrite_rules();
}
Example #2
0
/**
 * Get the default plugin's options and their values.
 *
 * @package WP Idea Stream
 * @subpackage core/options
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream_get_version()
 * @uses   wp_idea_stream_is_pretty_links() to check if pretty links are on
 * @uses   apply_filters() call 'wp_idea_stream_get_default_options' to override options values
 * @return array Filtered option names and values
 */
function wp_idea_stream_get_default_options()
{
    // Default options
    $default_options = array('_ideastream_version' => wp_idea_stream_get_version(), '_ideastream_archive_title' => 'IdeaStream', '_ideastream_submit_status' => 'publish', '_ideastream_editor_image' => 1, '_ideastream_editor_link' => 1, '_ideastream_moderation_message' => '', '_ideastream_login_message' => '', '_ideastream_hint_list' => '', '_ideastream_sticky_ideas' => 1, '_ideastream_disjoin_comments' => 1, '_ideastream_allow_comments' => 1, '_ideastream_embed_profile' => 0, '_ideastream_featured_images' => 1);
    // Pretty links customization
    if (wp_idea_stream_is_pretty_links()) {
        $default_options = array_merge($default_options, array('_ideastream_root_slug' => _x('ideastream', 'default root slug', 'wp-idea-stream'), '_ideastream_idea_slug' => _x('idea', 'default idea slug', 'wp-idea-stream'), '_ideastream_category_slug' => _x('category', 'default category slug', 'wp-idea-stream'), '_ideastream_tag_slug' => _x('tag', 'default tag slug', 'wp-idea-stream'), '_ideastream_user_slug' => _x('user', 'default user slug', 'wp-idea-stream'), '_ideastream_user_comments_slug' => _x('comments', 'default comments slug', 'wp-idea-stream'), '_ideastream_user_rates_slug' => _x('ratings', 'default ratings slug', 'wp-idea-stream'), '_ideastream_signup_slug' => _x('sign-up', 'default sign-up action slug', 'wp-idea-stream'), '_ideastream_action_slug' => _x('action', 'default action slug', 'wp-idea-stream'), '_ideastream_addnew_slug' => _x('add', 'default add idea action slug', 'wp-idea-stream'), '_ideastream_edit_slug' => _x('edit', 'default edit idea action slug', 'wp-idea-stream'), '_ideastream_cpage_slug' => _x('cpage', 'default comments pagination slug', 'wp-idea-stream')));
    }
    // Multisite options
    if (is_multisite()) {
        $default_options = array_merge($default_options, array('_ideastream_allow_signups' => 0, '_ideastream_user_new_idea_set_role' => 0));
    }
    /**
     * Used internally to merge options of the previous verions
     * of the plugin with new ones during upgrade routine.
     *
     * @see  core/upgrade wp_idea_stream_merge_legacy_options()
     *
     * @param  array $default_options list of options
     */
    return apply_filters('wp_idea_stream_get_default_options', $default_options);
}
/**
 * Adds needed scripts to rate the idea or add tags to it
 *
 * @package WP Idea Stream
 * @subpackage ideas/functions
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream_is_ideastream() to check it's plugin territory
 * @uses   wp_idea_stream_is_single_idea() to check if a single idea is displayed
 * @uses   wp_idea_stream_is_edit() to check if the idea is being edited
 * @uses   wp_idea_stream_is_rating_disabled() to check if ratings are enabled
 * @uses   wp_idea_stream_count_ratings() to get the idea rating stats
 * @uses   wp_idea_stream_get_hint_list() to get the rating captions
 * @uses   wp_idea_stream_users_current_user_id() to get current user ID
 * @uses   wp_create_nonce() to create a nonce to be check when rating an idea
 * @uses   wp_idea_stream_user_can() to check user's capability
 * @uses   wp_enqueue_script() to add the needed scripts to WordPress queue
 * @uses   wp_idea_stream_get_js_script() to get a specific javascript
 * @uses   wp_idea_stream_get_version() to get plugin's version
 * @uses   wp_localize_script() to localized script datas
 * @uses   wp_idea_stream_is_addnew() to check the form is displayed
 * @uses   wp_idea_stream_get_single_idea_id() to get current idea ID
 * @uses   apply_filters() call 'wp_idea_stream_ideas_single_script' to add data to scripts used on single idea
 *                         call 'wp_idea_stream_ideas_form_script_vars' to add data to scripts used when using the form
 */
function wp_idea_stream_ideas_enqueue_scripts()
{
    if (!wp_idea_stream_is_ideastream()) {
        return;
    }
    // Single idea > ratings
    if (wp_idea_stream_is_single_idea() && !wp_idea_stream_is_edit() && !wp_idea_stream_is_rating_disabled()) {
        $ratings = (array) wp_idea_stream_count_ratings();
        $users_nb = count($ratings['users']);
        $hintlist = (array) wp_idea_stream_get_hint_list();
        $js_vars = array('raty_loaded' => 1, 'ajaxurl' => admin_url('admin-ajax.php', 'relative'), 'wait_msg' => esc_html__('Saving your rating, please wait', 'wp-idea-stream'), 'success_msg' => esc_html__('Thanks, the average rating is now:', 'wp-idea-stream'), 'error_msg' => esc_html__('OOps, something went wrong', 'wp-idea-stream'), 'average_rate' => $ratings['average'], 'rate_nb' => $users_nb, 'one_rate' => esc_html__('One rate', 'wp-idea-stream'), 'x_rate' => esc_html__('% rates', 'wp-idea-stream'), 'readonly' => true, 'can_rate' => wp_idea_stream_user_can('rate_ideas'), 'not_rated' => esc_html__('Not rated yet', 'wp-idea-stream'), 'hints' => $hintlist, 'hints_nb' => count($hintlist), 'wpnonce' => wp_create_nonce('wp_idea_stream_rate'));
        $user_id = wp_idea_stream_users_current_user_id();
        if (wp_idea_stream_user_can('rate_ideas')) {
            $js_vars['readonly'] = 0 != $users_nb ? in_array($user_id, $ratings['users']) : false;
        }
        wp_enqueue_script('wp-idea-stream-script', wp_idea_stream_get_js_script('script'), array('jquery-raty'), wp_idea_stream_get_version(), true);
        wp_localize_script('wp-idea-stream-script', 'wp_idea_stream_vars', apply_filters('wp_idea_stream_ideas_single_script', $js_vars));
    }
    // Form > tags
    if (wp_idea_stream_is_addnew() || wp_idea_stream_is_edit()) {
        // Default dependencies
        $deps = array('tagging');
        // Defaul js vars
        $js_vars = array('tagging_loaded' => 1, 'taginput_name' => 'wp_idea_stream[_the_tags][]', 'duplicate_tag' => __('Duplicate tag:', 'wp-idea-stream'), 'forbidden_chars' => __('Forbidden character:', 'wp-idea-stream'), 'forbidden_words' => __('Forbidden word:', 'wp-idea-stream'));
        // Add HeartBeat if idea is being edited
        if (wp_idea_stream_is_edit()) {
            $deps = array_merge($deps, array('heartbeat'));
            $js_vars = array_merge($js_vars, array('idea_id' => wp_idea_stream_get_single_idea_id(), 'pulse' => 'fast', 'warning' => esc_html__('An admin is currently editing this idea, please try to edit your idea later.', 'wp-idea-stream')));
        }
        // Enqueue and localize script
        wp_enqueue_script('wp-idea-stream-script', wp_idea_stream_get_js_script('script'), $deps, wp_idea_stream_get_version(), true);
        wp_localize_script('wp-idea-stream-script', 'wp_idea_stream_vars', apply_filters('wp_idea_stream_ideas_form_script_vars', $js_vars));
    }
}
Example #4
0
/**
 * Credits screen
 *
 * @package WP Idea Stream
 * @subpackage admin/thanks
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream_get_version() to get plugin's version
 * @uses   add_query_arg() to add query vars to an url
 * @uses   admin_url() to build a link inside the current blog's Administration
 * @return string HTML output
 */
function wp_idea_stream_admin_credits()
{
    $display_version = wp_idea_stream_get_version();
    $settings_url = add_query_arg('page', 'ideastream', admin_url('options-general.php'));
    ?>
	<div class="wrap about-wrap">
		<h1><?php 
    printf(esc_html_x('WP Idea Stream %s', 'credit screen title', 'wp-idea-stream'), $display_version);
    ?>
</h1>
		<div class="about-text"><?php 
    printf(esc_html__('%s version of WP Idea Stream was also successfully released thanks to them!', 'wp-idea-stream'), $display_version);
    ?>
</div>
		<div class="wp-idea-stream-badge"></div>

		<h2 class="nav-tab-wrapper">
			<a class="nav-tab" href="<?php 
    echo esc_url(admin_url(add_query_arg(array('page' => 'about-ideastream'), 'index.php')));
    ?>
">
				<?php 
    esc_html_e('About', 'wp-idea-stream');
    ?>
			</a>
			<a class="nav-tab nav-tab-active" href="<?php 
    echo esc_url(admin_url(add_query_arg(array('page' => 'credits-ideastream'), 'index.php')));
    ?>
">
				<?php 
    esc_html_e('Credits', 'wp-idea-stream');
    ?>
			</a>
		</h2>

		<div class="changelog">
			<h4 class="wp-people-group"><?php 
    _e('The team!', 'wp-idea-stream');
    ?>
</h4>
			<ul class="wp-people-group " id="wp-people-group-core-team">
				<li class="wp-person" id="wp-person-imath">
					<a href="http://profiles.wordpress.org/imath"><img src="http://0.gravatar.com/avatar/8b208ca408dad63888253ee1800d6a03?s=60" class="gravatar" alt="Mathieu Viet" /></a>
					<a class="web" href="http://profiles.wordpress.org/imath">imath</a>
					<span class="title"><?php 
    _e('Creator', 'wp-idea-stream');
    ?>
</span>
				</li>
				<li class="wp-person" id="wp-person-aglekis">
					<a href="http://profiles.wordpress.org/aglekis"><img src="http://0.gravatar.com/avatar/9aed4c3373374032e4ecdde02894d5fb?s=60" class="gravatar" alt="Grégoire Noyelle" /></a>
					<a class="web" href="http://profiles.wordpress.org/aglekis">Grégoire Noyelle</a>
					<span class="title"><?php 
    _e('Contributor', 'wp-idea-stream');
    ?>
</span>
				</li>
			</ul>
		</div>

		<div class="changelog">
			<h4 class="wp-people-group"><?php 
    esc_html_e('Special thanks.', 'wp-idea-stream');
    ?>
</h4>
			<div class="ideastream-credits">
				<a href="https://paris.wordcamp.org/2016/"><img src="https://cldup.com/UoFilD4UGh.png" class="gravatar" alt="WordCamp Paris 2016" /></a>
			</div>
			<p><?php 
    printf(esc_html__('WP Idea Stream was the choice of the WordCamp Paris 2016 organization team to manage their &quot;Call for Speakers&quot;. Some requested features were very specific to their need and were all added as custom hooks in the %s file.', 'wp-idea-stream'), '<a href="https://github.com/imath/wc-talk">wp-idea-stream-custom.php</a>');
    ?>
</p>
			<p><?php 
    esc_html_e('The plugin was completely transformed to let the speakers submit their talks privately. The managing team was able to discuss together using private comments and evaluate each talk using the built-in rating system.', 'wp-idea-stream');
    ?>
</p>
			<p><?php 
    esc_html_e('Many thanks to WordCamp Paris organizers and speakers for this great experience and for their contributions to the user rates bug report.', 'wp-idea-stream');
    ?>
</p>
		</div>

		<h4 class="wp-people-group"><?php 
    esc_html_e('WP Idea Stream&#39;s external libraries and useful code', 'wp-idea-stream');
    ?>
</h4>
		<ul class="wp-people-group " id="wp-people-group-project-leaders">
			<li class="wp-person" id="wp-person-sniperwolf">
				<a href="https://github.com/sniperwolf"><img src="https://avatars1.githubusercontent.com/u/741938?v=2&s=60" class="gravatar" alt="Fabrizio Fallico" /></a>
				<a class="web" href="https://github.com/sniperwolf">Fabrizio Fallico</a>
				<span class="title"><a href="https://github.com/sniperwolf/taggingJS">taggingJS</a></span>
			</li>
			<li class="wp-person" id="wp-person-wbotelhos">
				<a href="https://github.com/wbotelhos"><img src="https://avatars2.githubusercontent.com/u/116234?v=2&s=60" class="gravatar" alt="Washington Botelho" /></a>
				<a class="web" href="https://github.com/wbotelhos">Washington Botelho</a>
				<span class="title"><a href="https://github.com/wbotelhos/raty">Raty</a></span>
			</li>
			<li class="wp-person" id="wp-person-garyjones">
				<a href="https://github.com/GaryJones"><img src="https://avatars3.githubusercontent.com/u/88371?v=2&s=60" class="gravatar" alt="Gary Jones" /></a>
				<a class="web" href="https://github.com/GaryJones">Gary Jones</a>
				<span class="title"><a href="https://github.com/GaryJones/Gamajo-Template-Loader">Template Loader class</a></span>
			</li>
		</ul>

		<div class="changelog">
			<div class="return-to-dashboard">
				<a href="<?php 
    echo esc_url($settings_url);
    ?>
" title="<?php 
    esc_html_e('Configure WP Idea Stream', 'wp-idea-stream');
    ?>
"><?php 
    esc_html_e('Go to the IdeaStream Settings page', 'wp-idea-stream');
    ?>
</a>
			</div>
		</div>

	</div>
	<?php 
}
/**
 * Loads the embed stylesheet to be used inside
 * WordPress & IdeaStream embed templates
 *
 * @since 2.3.0
 */
function wp_idea_stream_enqueue_embed_style()
{
    $min = '.min';
    if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
        $min = '';
    }
    wp_enqueue_style('wp-idea-stream-embed-style', wp_idea_stream_get_stylesheet("embed-style{$min}"), array(), wp_idea_stream_get_version());
}
Example #6
0
/**
 * Enqueue specific scripts and styles (if needed) to let any
 * user get the displayed user's embed link
 *
 * @since  2.3.0
 */
function wp_idea_stream_buddypress_enqueue_profile_sharing_dialog_css()
{
    if (!wp_idea_stream_is_embed_profile()) {
        return;
    }
    wp_enqueue_script('wp-idea-stream-script', wp_idea_stream_get_js_script('script'), array('jquery'), wp_idea_stream_get_version(), true);
    wp_localize_script('wp-idea-stream-script', 'wp_idea_stream_vars', apply_filters('wp_idea_stream_users_current_profile_script', array('is_profile' => 1)));
    $min = '.min';
    if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
        $min = '';
    }
    wp_enqueue_style('wp-idea-stream-sharing-profile', includes_url("css/wp-embed-template{$min}.css"), array(), wp_idea_stream_get_version());
}
Example #7
0
 /**
  * Loads the needed scripts for the Groups autocomplete control
  *
  * @package WP Idea Stream
  * @subpackage buddypress/groups
  *
  * @since  2.0.0
  *
  * @param  string $hooksuffix the admin page being loaded
  * @uses   wp_idea_stream_is_admin() to check for any IdeaStream Administration screens
  * @uses   bp_loggedin_user_id() to get current user's ID
  * @uses   get_post_field() to get the idea author
  * @uses   wp_enqueue_script() to add the script to WordPress queue
  * @uses   wp_idea_stream_get_js_script() to get a specific javascript
  * @uses   wp_idea_stream_get_version() to get plugin's version
  * @uses   wp_localize_script() to internatianlize data used in the script
  */
 public function admin_scripts($hooksuffix = '')
 {
     if (!in_array($hooksuffix, array('post-new.php', 'post.php')) || !wp_idea_stream_is_admin()) {
         return;
     }
     $js_vars = array('is_admin' => 1, 'author' => bp_loggedin_user_id());
     if (!empty($_GET['post'])) {
         $js_vars['author'] = get_post_field('post_author', absint($_GET['post']));
     }
     wp_enqueue_script('wp-idea-stream-admin-script', wp_idea_stream_get_js_script('script'), array('jquery', 'wp-ajax-response', 'jquery-ui-autocomplete'), wp_idea_stream_get_version(), true);
     wp_localize_script('wp-idea-stream-admin-script', 'wp_idea_stream_vars', $js_vars);
 }
Example #8
0
/**
 * Enqueues Users description editing scripts
 *
 * @package WP Idea Stream
 * @subpackage users/functions
 *
 * @since 2.0.0
 *
 * @uses wp_idea_stream_is_ideastream() to check it's plugin's territory
 * @uses wp_idea_stream_is_current_user_profile() to check the current user is on his profile
 * @uses wp_enqueue_script() to add the script to WordPress queue
 * @uses wp_idea_stream_get_js_script() to get a specific javascript
 * @uses wp_idea_stream_get_version() to get plugin's version
 * @uses wp_localize_script() to internatianlize data used in the script
 * @uses apply_filters() Calls 'wp_idea_stream_users_current_profile_script' to override/add new datas
 */
function wp_idea_stream_users_enqueue_scripts()
{
    if (!wp_idea_stream_is_user_profile()) {
        return;
    }
    // Viewing another user's profile with no sharing dialog box doesn't need js.
    if (!wp_idea_stream_is_current_user_profile() && !wp_idea_stream_is_embed_profile()) {
        return;
    }
    $js_vars = array('is_profile' => 1);
    if (wp_idea_stream_is_current_user_profile()) {
        $js_vars['profile_editing'] = 1;
    }
    wp_enqueue_script('wp-idea-stream-script', wp_idea_stream_get_js_script('script'), array('jquery'), wp_idea_stream_get_version(), true);
    wp_localize_script('wp-idea-stream-script', 'wp_idea_stream_vars', apply_filters('wp_idea_stream_users_current_profile_script', $js_vars));
}