Forum Replies Created

Viewing 15 replies - 31 through 45 (of 62 total)
  • Thread Starter edtiley

    (@edtiley)

    I’ve looked at this one before. If only it could be piggybacked onto Theme My Login. Does Mr. Farthing know Miled?

    As for Multisitable (great term!) the only clue is a diagnostic sent to them with support requests includes the value of is_multisite(). Switch_to_blog is nowhere in the source code.

    Really I plan four levels of user:
    Readers – No account needed
    Subscribers – Must be logged in to rate and comment
    Contributors – Authors
    Premium Contributors – upgrades like domain mapping, extra storage, etc.

    Subscribers are read-only, except for commenting and doing ratings, so social logins would be more than adequate.

    Contributors would need a more robust registration obviously both to maintain accountability and to be the platform for premium features.

    Thread Starter edtiley

    (@edtiley)

    True registrations or just comments?

    Really, must you ask such loaded questions?!

    Seriously, I have an open mind. I’ve read the pros and cons of Intense Debate, Disqus, and Livefyre, as well as a blog entry about the virtues of the core WP comment system.

    The only thing I think I’ve decided is that initial registrations gets you subscriber role. Subscribers can then register their own blog. It just seems to me that the double opt-in will reduce spam at least a little bit.

    I’d like to have commenter ranking/trust features like the plugins, but can do without while I see if the site is viable as a self-sustaining entity. I’d REALLY like a user rating plugin that would require someone to reach a certain level before they’re invited to create their own site, but I’m likely to have to write that one myself someday.

    The operative criteria are that I’m a solitary old Geezer with no budget and no staff. I need to be able to moderate the thing on my own as it grows enough to support a worker bee or two.

    Thread Starter edtiley

    (@edtiley)

    Again, interesting.

    not right so say Twenty Twelve breaks your plugin

    I’m an old newspaper guy. Never let facts get in the way of a good headline! At any rate it sparked an interesting thread, and I learned a couple of things.

    crucial to the functionality of the plugin

    If it weren’t crucial it shouldn’t be in the stylesheet

    add more specificity

    The logic of that is unassailable. It’s one of those concepts that just kind of makes you say, “Oh yeah, I should have thought of that!”

    Thread Starter edtiley

    (@edtiley)

    Interesting. Sorry to channel Mr. Spock.

    I modified the plugin adding the 20, and if you look at the source on http://www.thecoastline.com you’ll see that the plugin’s CSS loads after the theme’s.

    Now the question is, philosophically as much as technically, which is better? Should the plugin break the theme? Or should the theme break the plugin?

    In the end, one should have priority over the other. But which is “best practice?”

    I’m going to unhook resolved just in case someone wants to chime in on that one. Matt?

    Thread Starter edtiley

    (@edtiley)

    add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_styles' ) );

    What hook would you suggest other than wp_enqueue_scripts?

    The codex warns against using wp_print_styles on front pages.
    The setup_theme hook has already come and gone, so I’m thinking that it is somehow a “feature” that the theme’s css file loads last.

    A single “! important” is hardly a big PITA.

    Thread Starter edtiley

    (@edtiley)

    OMG thank you!

    It would have taken me several days more to figure that out! Offending code is right.

    Thank you to the lady from Wales, from a descendent of coal miners from the (now overgrown and gone) Welsh village of Tiley.

    Thread Starter edtiley

    (@edtiley)

    ROFL! I never have claimed to be normal.

    The db training and experience voices in my head (two of the four) say not to waste disk space duplicating every post.

    And hey, I learned a lot about the save_post hook, so it’s not a total loss in WP education. <grin>

    Thanks for your help.

    Ed

    Thread Starter edtiley

    (@edtiley)

    The simplest answer, I suppose is because when I read the code for sitewide tags, I thought it was perhaps a bit of an overkill for what I wanted to do.

    I do mostly understand the logic behind the code for sitewide, but I come from the olden days (WordStar’s DataStar) of CPM when databases were stored in CSV format. So I understand well how to wring every bit of value out of a single (flat file) table.

    Rather than create a blog to act as a library of sorts, my plugin uses a single table to store a fraction of the data, rather than use a large portion of the database to replicate data.

    The blog id and post id, title, a list of categories and tags, author nicename, and the GUID are all I store from the orginal post. Just enough to find and embellish a post in order to put a link to it on the main portal page if warranted. The other fields in the table register the results of user evaluations. I decided that I would prefer to have that information centrally located rather than spread it in metadata throught the database, which is what makes MultiSite hard to aggregate in the first place.

    This way I can pick off sitewide posts by several criteria, and link from the portal back to the author’s home blog with very little switch_to_blog activity on the portal’s front page. This design also makes it possible to aggregate trending keywords from a single table, and for cron jobs (not WP_cron) running every few minutes to create textual (JSON, XML ?) files that can be polled by custom front page widgets to display posts by the critera needed, thus making life easier for both MySQL and whatever page cache plugin I end up with.

    Sorry, didn’t mean to be so long winded, but is my logic off? God knows I don’t want to be reported to the House committee on Anti-WordPress Activities for not using the existing data structures.

    Thread Starter edtiley

    (@edtiley)

    Oh, I think you misunderstand my question.

    I’m not talking about going outside wpdb-> to make the calls. The question is if I have the proper wpdb->prefix for the main blog, does the routine even need to use switch_to_blog() to update that table.

    Thread Starter edtiley

    (@edtiley)

    OK, good to know.

    Actually, I’m wondering if I globalize or DEFINE the wpdb->prefix

    But can it be avoided altogether by specifying the table overtly?

    Thnks.

    Thread Starter edtiley

    (@edtiley)

    but it’s still something I wouldn’t use, say, seven times on one page.

    Oh, no. I’m crazy not stupid!!

    I’ve written a plugin that has some similarities to “sitewide tags” but in mine a table gets created in the main blog (id=1) and every post gets a record that stores the blog id, post id, author nicename, guid, a list of the categories, a list of the tags, how many times the post has been viewed, reader rating info, etc.

    When a post is created or updated:

    add_action('save_post',array($this,'new_post_added') );
    
    	function new_post_added($postinfo) {
    
    	global $wpdb , $post , $blog_id;
    
    	$postid = $postinfo;
    	$user_blog = $blog_id ;
    	$sql =  "SELECT * FROM " . $wpdb->get_blog_prefix( $blog_id ) . "posts WHERE id=" . $postid ;
     	$newpost = $wpdb->get_row($sql);
    
     	if ( $newpost->post_type == 'post' && $newpost->post_status == 'publish' ) {
    
    		$title = $newpost->post_title ;
    		$author = get_the_author_meta( 'display_name', $newpost->post_author );
    		$pageurl = get_permalink() ;
    		$catnams ='';
    			foreach (get_the_category() as $cat)
      	  	{
      	     	$catnams .= ' | ' . $cat->cat_name ;
      	  	}
    		$catnams = ltrim(substr($catnams,2));
    
    		$tagnams =  strip_tags(get_the_tag_list('',' | ',''));
    //		$tagnams = ltrim(substr($tagnams,2));
    
    		$wpdb->flush();
    		switch_to_blog(1);
    		$table_name = $wpdb->prefix . "ipubratings";
    		$sql =  "SELECT * FROM " . $table_name . " WHERE post_id =" . $postid . " AND blog_id = " . $user_blog   ;
     		$starpost = $wpdb->get_row($sql);
    
    		if ( !empty( $starpost->rating_id ) ) {
    
    			 $wpdb->update( $table_name , array(
    						'post_title' => $title,
    						'author' => $author,
    						'pageurl' => $pageurl,
    						'cat_list' => $catnams,
    						'tag_list' => $tagnams),
    						array('rating_id' => $starpost->rating_id)
    					);
    		} else {
    
    			 $wpdb->insert( $table_name , array(
    						'blog_id' => $user_blog,
    						'rating_date' => current_time( 'mysql',1),
    						'post_id' => $postid,
    						'post_title' => $title,
    						'author' => $author,
    						'pageurl' => $pageurl,
    						'cat_list' => $catnams,
    						'tag_list' => $tagnams,
    						'voters' => '|')
    			);
    		} // end ! empty
    	restore_current_blog() ;
    
        } // end if  published post
    	} // end new post added

    I’m just worried that if the site gets really busy that the switch might be too resource hungry.

    Actually, I’m wondering if I globalize or DEFINE the wpdb->prefix for the main blog id if I can create a method in the plugin’s class that would be able to access and maintain the ipubratings table without switching blogs. Seems I tried that, but it didn’t work out too well, but then I’m not nearly as good a coder as I was twenty years ago. Sigh…

    My goal is to come to understand MultiSite half as well as you and Andrea! You two are an MU-Treasure. (not fawning) Thanks.

    Thread Starter edtiley

    (@edtiley)

    And no, you can’t have grandchildren

    Well, I do have two… <grin>

    That’s again unfortunate. My child theme is based on twenty-twelve, and the code changes would be the same for all the variations. Thus all the “enhanced” templates could be the main child, and its children could contain just the CSS, background images, etc. That way I’d be able to have just one copy of the templates to maintain.

    I guess I’m going to have to write plugin code that instantiates one or two additional sidebar areas, then hard codes the content for them instead of being able to widgetize them.

    In my wishlist dreams you’d be able to create a network site to clone from, and be able to specify what menus and sidebars from that site could be inherited by other sites.

    Sigh…

    Thank you for your help.

    Ed

    Thread Starter edtiley

    (@edtiley)

    I assume you mean something like editing sidebar.php (or its equivalent). That’s unfortunate because it limits choices of themes for users. I was planning to limit users to child themes of twenty-twelve anyhow, so…. That triggers two questions:

    Is it possible/practical to have grandchild themes? That is a child theme of a child theme, so the extended programming is separated from the styling.

    Is there a good example plugin that shows how to build a screen for the superAdmin Dashboard to be able to control ad rotation etc.?

    Thanks,

    Ed

    Thread Starter edtiley

    (@edtiley)

    I got no idea what this says exept NIKE.

    I think it’s possibly spammy, but I don’t speake Polish.

    Thread Starter edtiley

    (@edtiley)

    Putting it in functions.php makes it globally available.

    $this->foo();
    Bingo! I searched unsuccessfully for that for hours. In all the tuts I’ve read on building class based plugins I don’t think that little construct was explicitly mentioned. Or at least failed to penetrate my grayRAM.

    Thanks.

    Ed

Viewing 15 replies - 31 through 45 (of 62 total)