Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • in reply to: Social Articles Restriction #16034
     mckown
    Participant

    Ok, here’s a quick solution. Just completely replace plugins/social-articles/includes/templates/members/single/articles/new.php with the code below.
    If you’d like to change the message displayed to the member it’s on line 162
    To grant access just switch a users role to contributor.

    I’m thinking I’ll come back later and make it to where if a non-author clicks their blog icon it redirects to a page explaining how to become an author .. but for now this works.

    COPY CODE
    
    <?php
    global $post, $wpdb, $bp, $socialArticles;
    
    $directWorkflow = isDirectWorkflow();
    
    $statusLabels = array("publish"=>__('Published', 'social-articles'), 
                            "draft"=>__('Draft', 'social-articles'), 
                          "pending"=>__('Under review', 'social-articles'), 
                         "new-post"=>__('New', 'social-articles'));
    ?>
    <?php if(isset($_GET['article'])):    
           $myArticle = get_post($_GET['article']);
           $post_id = $_GET['article'];
           if(isset($myArticle) && $myArticle->post_author == bp_loggedin_user_id() && ($socialArticles->options['allow_author_adition']=="true" || $myArticle->post_status=="draft")){
               $state = "ok";           
               $title = $myArticle->post_title;
               $content = $myArticle->post_content;             
               $status = $myArticle->post_status;
               $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($_GET['article']), 'large');       
               if(isset($large_image_url)){
                    $image_name = end(explode("/",$large_image_url[0]));
               }          
               ?>           
                <input type="hidden" id="mode" value="edit"/>
                <input type="hidden" id="feature-image-url" value="<?php echo $large_image_url[0];?>"/>    
               <?php
           }else{          
               $state = "error";
               $message = __("You cannot perform this action", "social-articles");
           }     
           ?>        
    <?php else:
           $post_id = 0;  
           $status = "new-post";
           ?>        
           <input type="hidden" id="mode" value="new"/>    
    <?php endif;?>
    
    <input type="hidden" id="image-name" value="<?php echo $image_name;?>"/>
    <input type="hidden" id="categories-ids"/>
    <input type="hidden" id="tag-ids"/>
    <input type="hidden" id="tag-names"/>
    <input type="hidden" id="categories-names"/>
    <input type="hidden" id="post-id" value="<?php echo $post_id;?>"/>   
    <input type="hidden" id="post-status" value="<?php echo $status;?>"/>
    <input type="hidden" id="direct-workflow" value="<?php echo $directWorkflow;?>"/>
    
    <?php if(!isset($_GET['article']) || $state == "ok"):?>
        <div class="post-save-options messages-container"> 
            <label id="save-message"></label>
            <input type="submit" id="edit-article" class="button" value="<?php _e("Edit article", "social-articles"); ?>" />
            <input type="submit" id="view-article" class="button" value="<?php _e("View article", "social-articles"); ?>" />
            <input type="submit" id="new-article" class="button" value="<?php _e("New article", "social-articles"); ?>" />
        </div>
        <div id="post-maker-container">
        <?php if (current_user_can('edit_posts')):?>
            <div class="options">    
                <div class="options-content">
                    <span class="titlelabel"><?php _e("Categories", "social-articles"); ?></span>
                    <div class="categories-selector"><?php _e("Select your category", "social-articles"); ?></div>
                    <span class="picker" onmouseover="showCategoryList()"></span>
                    <span class="white-picker"></span>
                    <?php echo get_category_list($_GET['article']);?>
                </div>
                <div class="options-content options-content-second">
                    <label class="titlelabel"><?php _e("Tags", "social-articles"); ?></label>    
                    <div class="tags-selector"><?php _e("Select your tags", "social-articles"); ?></div>
                    <span class="picker-t" onmouseover="showTagsList()"></span>
                    <span class="white-picker-t"></span>        
                    <?php echo get_tags_list($_GET['article']);?>
                </div>
                
                <div class="post-status-container options-content">
                    <label class="titlelabel"><?php _e("Status", "social-articles"); ?></label>             
                    <span class="article-status <?php echo $status;?>"><?php echo $statusLabels[$status];?></span>                                             
                </div>
            </div>
               
            <input type="text" id="post_title" class="title-input" autofocus placeholder="<?php _e("Article title...", "social-articles"); ?>" value="<?php echo $title; ?>"/>
            
            <div class="editor-container">
                <div id="wysihtml5-editor-toolbar">
                  <header>
                    <ul class="commands">
                      <li data-wysihtml5-command="bold" title="Bold (CTRL + B)" class="command"></li>
                      <li data-wysihtml5-command="italic" title="Italic (CTRL + I)" class="command"></li>
                      <li data-wysihtml5-command="insertUnorderedList" title="<?php _e('Insert unordered list', 'social-articles');?>" class="command"></li>
                      <li data-wysihtml5-command="insertOrderedList" title="<?php _e('Insert ordered list', 'social-articles');?>" class="command"></li>
                      <li data-wysihtml5-command="createLink" title="<?php _e('Insert link', 'social-articles');?>" class="command"></li>         
                      <li data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h2" title="<?php _e('Title', 'social-articles');?>" class="command"></li>          
                      <li data-wysihtml5-command-group="foreColor" class="fore-color" title="Color the selected text" class="command">
                        <ul>
                          <li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="silver"></li>
                          <li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="gray"></li>
                          <li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="maroon"></li>
                          <li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="red"></li>
                          <li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="purple"></li>
                          <li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="green"></li>
                          <li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="olive"></li>
                          <li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="navy"></li>
                          <li data-wysihtml5-command="foreColor" data-wysihtml5-command-value="blue"></li>
                        </ul>
                      </li>        
                    </ul>
                  </header>
                  <div data-wysihtml5-dialog="createLink" style="display: none;">
                    <label>
                      Link:
                      <input data-wysihtml5-dialog-field="href" value="http://">
                    </label>
                    <a><?php _e("OK", "social-articles"); ?></a> <a><?php _e("Cancel", "social-articles"); ?></a>
                  </div>      
                </div>
                
                <section>
                    <div class="textarea-container">
                        <textarea id="wysihtml5-editor" spellcheck="false" wrap="off" placeholder="<?php _e("Article content...", "social-articles"); ?>">           
                            <?php echo $content;?>         
                        </textarea>                
                    </div>
                </section>
                
            </div>        
            
            <div id="post_image" class="post-image-container">
                <div class="image-preview-container" id="image-preview-container">
                </div>    
                <div class="upload-controls">
                    <input id="uploader" type="submit" class="button" value="<?php _e("Upload Image", "social-articles"); ?>" />     
                    <label><?php _e("Max size allowed is 2 MB", "social-articles"); ?></label>
                </div>    
                <div class="uploading" id="uploading">
                   <img />/assets/images/load.gif"/>
                   <label><?php _e("Uploading your image. Please wait.", "social-articles"); ?></label>
                </div>  
                
                <div class="edit-controls">
                    <input type="submit" class="button" value="<?php _e("Delete", "social-articles"); ?>" onclick="cancelImage()" /> 
                </div>    
            </div> 
            
            <div id="save-waiting" class="messages-container">
                 <img />/assets/images/load.gif"/>
                 <label><?php _e("Saving your article. Please wait.", "social-articles"); ?></label>        
            </div>        
            <div id="error-box" class="messages-container">       
            </div>
            <div class="buttons-container" id="create-controls">
                <?php if(($status=="draft" || $status == "new-post") && !$directWorkflow):?>
                    <input type="checkbox" id="publish-save" /><label for="publish-save"><span></span><?php _e("Save and move it under review", "social-articles"); ?></label>
                <?php endif?>
                <?php if(($status=="draft" || $status == "new-post") && $directWorkflow):?>
                    <input type="checkbox" id="publish-save" /><label for="publish-save"><span></span><?php _e("Save and publish", "social-articles"); ?></label>
                <?php endif?>
    
                <input type="submit" class="button save" value="<?php _e("Save", "social-articles"); ?>" onclick="savePost(); return false;" />
                <input type="submit" class="button cancel" value="<?php _e("Cancel", "social-articles"); ?>" onclick="window.open('<?php echo $bp->loggedin_user->domain.'/articles';?>', '_self')" />
            </div>  
            
                <?php else:?>
        <div id="message" class="messageBox note icon">
            <span><?php _e("Sorry, you currently do not have author status.");?></span>
        </div>  
    <?php endif;?> 
            
        </div> 
      
    <?php else:?>
        <div id="message" class="messageBox note icon">
            <span><?php echo $message; ?></span>
        </div>    
    <?php endif;?>
    
    <script>
    
    jQuery(function(){   
        var editor = new wysihtml5.Editor("wysihtml5-editor", {
            toolbar:     "wysihtml5-editor-toolbar",
            stylesheets: ["http://yui.yahooapis.com/2.9.0/build/reset/reset-min.css", MyAjax.baseUrl+"/assets/css/editor.css"],
            parserRules: wysihtml5ParserRules
        });
    });  
    
    jQuery(function(){                    
        new AjaxUpload('uploader', {
            action: MyAjax.baseUrl+'/upload-handler.php',                
                    onComplete: function(file, response){                                       
                        response = jQuery.parseJSON(response);
                        jQuery("#uploading").hide();
                        if(response.status == "ok"){                                                           
                            jQuery("#image-name").val(response.value);
                            jQuery("#image-preview-container").html(getImageObject(MyAjax.tmpImageUrl+ response.value));
                            jQuery(".edit-controls").show();                                                    
                        }else{
                            jQuery(".upload-controls").show();   
                            showError(response.value);                                
                        }
                    },
                    onSubmit: function(file, extension){
                       jQuery('#error-box').hide();
                       jQuery(".upload-controls").hide();
                       jQuery("#uploading").show();                              
                    }   
                });         
            
            });             
    
    </script>
    
    in reply to: Link Author Meta to BP Profile #15837
     mckown
    Participant
    COPY CODE
    
    function kleo_entry_meta($echo=true, $att=array()) {
    	
    		$meta_list = array();
    		
    		// Translators: used between list items, there is a space after the comma.
    		$categories_list = get_the_category_list( __( ', ', 'kleo_framework' ) );
    
    		// Translators: used between list items, there is a space after the comma.
    		$tag_list = get_the_tag_list( '', __( ', ', 'kleo_framework' ) );
    
    		$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
    			esc_url( get_permalink() ),
    			esc_attr( get_the_time() ),
    			esc_attr( get_the_date( 'c' ) ),
    			esc_html( get_the_date() )
    		);
    
    		$author = sprintf( '<a href="%1$s" title="%2$s" rel="author">%3$s</a>',
    			esc_url( bp_core_get_user_domain( get_the_author_meta( 'ID' ) ) ),
    			esc_attr( sprintf( __( 'View all posts by %s', 'kleo_framework' ), get_the_author() ) ),
    			get_the_author()
    		);
    
    		$meta_list[] = '<small class="meta-author">'.$author.'</small>';
    		$meta_list[] = '<small>'.$date.'</small>';
    		
    		$cat_tag = array();
    		
    		if ( $categories_list ) {
    			$cat_tag[] = $categories_list;
    		}
    		
    		if ($tag_list) {
    			$cat_tag[] = $tag_list;
    		}
    		if (!empty($cat_tag)) {
    			$meta_list[] = '<small class="meta-category">'.implode(", ",$cat_tag).'</small>';
    		}
    		
    		//comments
    		if (!isset($att['comments']) || (isset($att['comments']) && $att['comments'] !== false)) {
    		$meta_list[] = '<small class="meta-comment-count"><a href="'. get_permalink().'#comments">'.get_comments_number().' <i class="icon-chat-1 hover-tip" 
    			data-original-title="'.sprintf( _n( 'This article has one comment', 'This article has %1$s comments', get_comments_number(), 'kleo_framework' ),number_format_i18n( get_comments_number() ) ).'" 
    			data-toggle="tooltip" 
    			data-placement="top"></i></a></small>';
    		}
    		
    		if ($echo) {
    			echo implode(", ", $meta_list);
    		}
    		else {
    			return implode(", ", $meta_list);
    		}
    		
    	}
    
    in reply to: Adding notification bubble to menu #15580
     mckown
    Participant

    Here’s an update:
    Includes the word “Messages” before the bubble
    Displays just in top nav menu and for logged in users only (if you want to switch to the other menu change ‘top’ to ‘primary’

    COPY CODE
    
    add_filter('wp_nav_menu_items','add_notification_to_custom_menu', 2, 2);
    
    function add_notification_to_custom_menu( $items, $args ) {
    if ( is_user_logged_in() ) {
    if( $args->theme_location == 'top' ){
    	$notifications = bp_notifications_get_notifications_for_user( bp_loggedin_user_id() );
    	$count         = ! empty( $notifications ) ? count( $notifications ) : 0;
    	if ($count > 0 ) {
    		$alert = 'alert';
    		$pending = 'pending-count';
    	} else {
    		$alert = 'no-alert';
    		$pending = 'count';
    	}
    	return $items."<li id='menu-bp-notifications' class='menu pop'><a href='".bp_loggedin_user_domain()."notifications/'>Messages <span id='ab-pending-notifications' class='" . $pending . " " . $alert . "'>".$count."</a></li>";
    }
    }
    	return $items;
    
    }
    
Viewing 3 posts - 1 through 3 (of 3 total)

Log in with your credentials

Forgot your details?