Skip to content

Commit

Permalink
Merge pull request #1 from cariboo/master
Browse files Browse the repository at this point in the history
Upgrade pour wp-idea-stream 1.0.3
  • Loading branch information
mxgnr committed Sep 13, 2012
2 parents 5bef275 + 7b8e55b commit 61f0f2d
Show file tree
Hide file tree
Showing 13 changed files with 161 additions and 144 deletions.
55 changes: 23 additions & 32 deletions includes/wp-idea-stream-add-new.php
@@ -1,30 +1,26 @@
<?php

global $wp_idea_stream_submit_errors, $current_user;

$ideastream_allow_guests = get_option('_ideastream_allow_guests');

if(!wp_verify_nonce($_POST['wp-ideastream-check'],'wp-ideastream-check-referrer')){
wp_die(__('You need to use the IdeaStream form to submit an idea', 'wp-idea_stream'));
}
if( !is_user_logged_in() ){
if ($ideastream_allow_guests == 1) {
if (!$_POST['_wp_is_guest_name']) {
$wp_idea_stream_submit_errors[] = __('Your name is required','wp-idea-stream');
}

if ($ideastream_allow_guests == 0 && !is_user_logged_in()) {
wp_die(__('You need to be a member of this site to submit an idea', 'wp-idea_stream'));
}

if ($ideastream_allow_guests == 1 && !is_user_logged_in()) {
if (!$_POST['_wp_is_guest_name']) {
$wp_idea_stream_submit_errors[] = __('Your name is required','wp-idea-stream');
}

if (!$_POST['_wp_is_guest_email']) {
$wp_idea_stream_submit_errors[] = __('Your e-mail is required','wp-idea-stream');
}
else {
$sanitized_email = sanitize_email($_POST['_wp_is_guest_email']);
if (empty($sanitized_email)) {
$wp_idea_stream_submit_errors[] = __('Your e-mail is not correct, please check again','wp-idea-stream');
if (!$_POST['_wp_is_guest_email']) {
$wp_idea_stream_submit_errors[] = __('Your e-mail is required','wp-idea-stream');
}
else {
$sanitized_email = sanitize_email($_POST['_wp_is_guest_email']);
if (empty($sanitized_email)) {
$wp_idea_stream_submit_errors[] = __('Your e-mail is not correct, please check again','wp-idea-stream');
}
}
} else {
wp_die(__('You need to be a member of this site to submit an idea', 'wp-idea_stream'));
}
}

Expand All @@ -34,17 +30,15 @@
if(!$_POST["content"]){
$wp_idea_stream_submit_errors[] = __('Content is required','wp-idea-stream');
}
if(!$_POST["_wp_is_category"]){
if(!$_POST["_wp_is_category"] || count($_POST["_wp_is_category"])==0){
$wp_idea_stream_submit_errors[] = __('Category is required','wp-idea-stream');
}

if(!$_POST['_wp_is_antispam']){
$wp_idea_stream_submit_errors[] = __('Antispam verification is required', 'wp-idea-steam');
}
elseif ($_POST['_wp_is_antispam'] != 10) {
$wp_idea_stream_submit_errors[] = __('Wrong antispam response, please check again', 'wp-idea-steam');
}

do_action('wp_idea_stream_check_extra_fields');


Expand All @@ -56,37 +50,33 @@

$post_title = wp_kses($_POST["_wp_is_title"], array());
$post_content = wp_kses($_POST["content"], wp_idea_stream_allowed_html_tags());

if ($ideastream_allow_guests == 1 && !is_user_logged_in()) {
//$post_author = '1'; // Specify the default authorID (which will be overwritted by post_meta below)
$post_guest_name = $_POST['_wp_is_guest_name'];
$post_guest_email = sanitize_email($_POST['_wp_is_guest_email']);
}
else {
} else {
$post_author = $current_user->ID;
}

$post_category = $_POST["_wp_is_category"];

$idea_status = get_option('_ideastream_submit_status');
if (!$idea_status || $idea_status=="") $idea_status = 'publish';
if(!$idea_status || $idea_status=="") $idea_status = 'publish';

$post = array(
'post_author' => $post_author,
'post_title' => $post_title,
'post_content' => $post_content,
'post_status' => $idea_status,
'post_type' => 'ideas'
'post_type' => 'ideas'
);

$new_post_id = wp_insert_post($post);

if ($ideastream_allow_guests == 1 && !is_user_logged_in()) {
add_post_meta($new_post_id, 'ideastream_guest_name', $post_guest_name, true);
add_post_meta($new_post_id, 'ideastream_guest_email', $post_guest_email, true);
}

do_action('wp_idea_stream_save_extra_fieds', $post_id);
do_action('wp_idea_stream_save_extra_fieds', $new_post_id);

//set category
if($post_category) wp_set_post_terms( $new_post_id, $post_category, 'category-ideas', false);
Expand All @@ -95,6 +85,7 @@
if($_POST['_wp_is_tags']) wp_set_post_terms( $new_post_id, str_replace(' ',',', $_POST['_wp_is_tags']), 'tag-ideas', false);

//redirect to published idea
if($idea_status == 'publish') wp_redirect( get_permalink($new_post_id) );
if($idea_status == 'publish') wp_redirect( get_permalink($post_id) );
else wp_redirect( wp_idea_stream_new_form().'?moderation=1');
?>
die();
?>
7 changes: 3 additions & 4 deletions includes/wp-idea-stream-options.php
@@ -1,12 +1,12 @@
<?php
//Idea Stream Options
if($_POST['_ideastream_save_options']){

//allow guests to post or not
if(get_option('_ideastream_allow_guests')!=$_POST['_ideastream_allow_guests']){
update_option('_ideastream_allow_guests', $_POST['_ideastream_allow_guests']);
}

//editor img and link button
$editor_options = array('image'=>intval($_POST['_idea_editor_image']),'link'=>intval($_POST['_idea_editor_link']));
update_option('_ideastream_editor_config', $editor_options);
Expand Down Expand Up @@ -98,7 +98,6 @@ function is_option_checked($option, $value){
<?php _e('Activate');?>&nbsp;
<input type="radio" value="0" name="_idea_editor_image" <?php if(is_option_checked($ideastream_editor_config['image'], 0)) echo "checked";?>>
<?php _e('Deactivate');?>
</td>
</tr>
<tr>
<td><label for="_idea_editor_link"><?php _e('Link Button (Wysiwyg Editor)','wp-idea-stream');?></label></td>
Expand Down Expand Up @@ -185,4 +184,4 @@ function is_option_checked($option, $value){
<input type="submit" name="_ideastream_save_options" value="<?php _e('Save IdeaStream Options', 'wp-idea-stream');?>" class="button-primary">
</div>
</form>
</div>
</div>
32 changes: 27 additions & 5 deletions includes/wp-idea-stream-templatetags.php
Expand Up @@ -355,28 +355,24 @@ function is_new_idea(){
}
else return false;
}

function is_all_ideas(){
if(ereg('feedback/all-ideas', $_SERVER['REQUEST_URI'])){
return true;
}
else return false;
}

function is_featured_ideas(){
if(ereg('feedback/featured-ideas', $_SERVER['REQUEST_URI'])){
return true;
}
else return false;
}

function is_idea_author(){
if(ereg('feedback/idea-author', $_SERVER['REQUEST_URI'])){
return true;
}
else return false;
}

function is_best_ideas(){
if(ereg('feedback/best-ideas', $_SERVER['REQUEST_URI'])){
return true;
Expand Down Expand Up @@ -406,4 +402,30 @@ function detect_author_idea() {
}
}

?>
/**
* Appeared in WP 3.4
*/
function wp_is_fix_css_editor(){
if( 3.4 <= wp_is_get_major_wp_version() ) {

if( is_multisite() )
$url = get_blog_option(1, 'siteurl');

else
$url = site_url();

wp_enqueue_style('style-editor', $url . '/' . WPINC .'/css/editor.css');
}
}

function wp_is_fix_editor_wp_lang_fatal_error() {
if ( 3.4 <= wp_is_get_major_wp_version() && ! class_exists('_WP_Editors' ) )
require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
}

function wp_is_get_major_wp_version() {
global $wp_version;

return (float) $wp_version;
}
?>
2 changes: 1 addition & 1 deletion includes/wp-idea-stream-widgets.php
Expand Up @@ -293,4 +293,4 @@ function _get_best_rated_ideas($instance){
}
}

?>
?>
5 changes: 3 additions & 2 deletions templates/all-ideas.php
Expand Up @@ -38,7 +38,7 @@

<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'wp-idea-stream' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

<div style="float: right;"><?php get_vote_it_up_button(); ?></div>

<div class="entry-meta">
Expand Down Expand Up @@ -70,6 +70,7 @@
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'wp-idea-stream' ), __( '1 Comment', 'wp-idea-stream' ), __( '% Comments', 'wp-idea-stream' ) ); ?></span>
<?php edit_post_link( __( 'Edit', 'wp-idea-stream' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-utility -->

</div>

<?php endwhile; // End the loop. Whew. ?>
Expand All @@ -83,4 +84,4 @@
</div><!-- content -->
</div>
<?php get_sidebar();?>
<?php get_footer();?>
<?php get_footer();?>
2 changes: 1 addition & 1 deletion templates/best-ideas.php
Expand Up @@ -29,4 +29,4 @@
</div><!-- content -->
</div>
<?php get_sidebar();?>
<?php get_footer();?>
<?php get_footer();?>
5 changes: 3 additions & 2 deletions templates/category-ideas.php
Expand Up @@ -6,6 +6,7 @@
* @subpackage WP Idea Stream
* @since WP Idea Stream 1.0
*/
header('HTTP/1.1 200 OK');
get_header()?>
<div id="container">
<div id="content" role="main">
Expand Down Expand Up @@ -41,7 +42,7 @@

<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'wp-idea-stream' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

<div style="float: right;"><?php get_vote_it_up_button(); ?></div>

<div class="entry-meta">
Expand Down Expand Up @@ -85,4 +86,4 @@
</div><!-- content -->
</div>
<?php get_sidebar();?>
<?php get_footer();?>
<?php get_footer();?>
4 changes: 2 additions & 2 deletions templates/featured-ideas.php
Expand Up @@ -30,7 +30,7 @@

<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'wp-idea-stream' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

<div style="float: right;"><?php get_vote_it_up_button(); ?></div>

<div class="entry-meta">
Expand Down Expand Up @@ -76,4 +76,4 @@
</div><!-- content -->
</div>
<?php get_sidebar();?>
<?php get_footer();?>
<?php get_footer();?>
4 changes: 3 additions & 1 deletion templates/idea-author.php
Expand Up @@ -6,6 +6,7 @@
* @subpackage WP Idea Stream
* @since WP Idea Stream 1.0
*/
header('HTTP/1.1 200 OK');
get_header(); ?>

<div id="container">
Expand Down Expand Up @@ -97,7 +98,7 @@

<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'wp-idea-stream' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

<div style="float: right;"><?php get_vote_it_up_button(); ?></div>

<div class="entry-meta">
Expand Down Expand Up @@ -145,3 +146,4 @@

<?php get_sidebar(); ?>
<?php get_footer(); ?>

2 changes: 1 addition & 1 deletion templates/new-idea.php
Expand Up @@ -15,4 +15,4 @@
</div>
</div>
<?php get_sidebar();?>
<?php get_footer();?>
<?php get_footer();?>
7 changes: 3 additions & 4 deletions templates/single-idea.php
Expand Up @@ -6,16 +6,15 @@
* @subpackage Twenty_Ten
* @since Twenty Ten 1.0
*/

header('HTTP/1.1 200 OK');
get_header(); ?>
<div id="container">
<div id="content" role="main">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="entry-title"><?php the_title(); ?></h1>



<div style="float: right;"><?php get_vote_it_up_button(); ?></div>

<div class="entry-meta">
Expand Down Expand Up @@ -73,4 +72,4 @@
</div><!-- #container -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>
<?php get_footer(); ?>
5 changes: 3 additions & 2 deletions templates/tag-ideas.php
Expand Up @@ -6,6 +6,7 @@
* @subpackage WP Idea Stream
* @since WP Idea Stream 1.0
*/
header('HTTP/1.1 200 OK');
get_header()?>
<div id="container">
<div id="content" role="main">
Expand Down Expand Up @@ -37,7 +38,7 @@

<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'wp-idea-stream' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

<div style="float: right;"><?php get_vote_it_up_button(); ?></div>

<div class="entry-meta">
Expand Down Expand Up @@ -81,4 +82,4 @@
</div><!-- content -->
</div>
<?php get_sidebar();?>
<?php get_footer();?>
<?php get_footer();?>

0 comments on commit 61f0f2d

Please sign in to comment.