Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thanks David, this was great and helped me a lot. I ran into the same issues when using the co-authors plus plugin. The name property doesn’t show up correctly, so it doesn’t properly assign people to the correct user role and it appears that the new users aren’t in the system (they are, but have no role associated with them.)

    Here are the code modifications I made:

    functions/settings.php line 201:

    //$roles = $wp_roles->get_names();
    $roles = get_editable_roles();

    then on line 205:

    foreach($roles as $key => $role) {
    	$thisrole = $key;

    In networkoptions.php I made pretty much the same modifications on line 340:

    //$roles = $wp_roles->get_names();
    $roles = get_editable_roles();

    347

    foreach($roles as $key => $role) {
    	$thisrole = $key;

    392

    foreach($roles as $key=>$role) {
    	$thisrole = $key;

    415

    foreach($roles as $key=>$role) {
    	$thisrole = $key;

    in commonfn.php here is how I change the class around lines 26ish:

    global $wpdb, $wp_roles;
    $roles = get_editable_roles(); //$wp_roles->get_names();
    
    $tempnames = new stdClass();
    foreach($roles as $key => $role){
    	$tempnames->$key = $key;
    }
    $this->lineroles = $tempnames;

    This mimicked the $wp_roles->get_names();, but with correct names.

    The key of the object has the correct role description which matches what’s in the database for me, even with custom roles. The name property has something else. Not sure if this is a good way to go about this, but it worked for me and perhaps it might work for someone else. Adding users was a one-time deal for me, and I uninstalled the plugin after that.

    Thread Starter jrue

    (@jrue)

    OK, I figured it out. I haven’t done too much with WordPress’s ajax hooks, so it took me a little bit of deciphering.

    For others who might want to do the same thing, it’s actually quite simple and done completely with JavaScript. If you query the URL of the post along with two timestamps—a from value and a to value—it will return the liveblog posts between those two values in JSON format.

    Here is the script I came up with for my purposes if it’s helpful to anyone. I just used 1 as my from value, to retrieve all posts. This probably isn’t very efficient at all, but it made it easy for me so I can display truncated versions of the top four or five liveblog posts for our front page to entice readers to click in.

    Anyone implementing this, I would encourage you to look at liveblog.js which has some fantastic timer scripts if you wanted to keep it livestreaming, similar to how it was built.

    Oh, and the code below is within the loop, and only works with permalinks that don’t use query strings:

    <?php if(class_exists('WPCOM_Liveblog') && (bool) get_post_meta($post->ID, 'liveblog', true)): ?>
    <script type="text/javascript" >
    jQuery(document).ready(function($) {
    
    	function success_callback(response, status, xhr){
    		console.log(response.entries);
    	}
    
    	function error_callback(response){
    		console.log(response);
    	}
    
    	function current_timestamp() {
    		return Math.floor( Date.now() / 1000 );
    	};
    
    	$.ajax( {
    		url: '<?php the_permalink(); ?>liveblog/1/' + current_timestamp() + '/',
    		data: {},
    		type: 'GET',
    		dataType: 'json',
    		success: success_callback,
    		error: error_callback
    	} );
    });
    </script>
    <?php endif; //end liveblog ?>

    @donmcint

    In order for a plugin to show up in the admin, you have to put some comment code at the top so that WordPress will detect is as a plugin. At the top of “chachacha.php” add the following:

    <?php
    /*
    Plugin Name: Theme Editor
    Plugin URI: https://www.ads-software.com/extend/plugins/
    Description: Allows Theme Editor in MU
    Author: jroakes
    Version: 0.1
    */

    After that, go into network admin, not just the admin of each site.

    Hope this helps.

    Hi All, I found the issues. It was two things.

    First: the Fatal Error I had was because I stupidly named the plugin the same name “theme-editor.php” Once I changed to something unique, that error went away.

    The permissions error dallasm was getting was fixed by commenting out a few additional lines of code in wp-admin/theme-editor.php

    Here is what needs to be commented out:

    /*
    if ( is_multisite() && ! is_network_admin() ) {
    	wp_redirect( network_admin_url( 'theme-editor.php' ) );
    	exit();
    }
    
    if ( !current_user_can('edit_themes') )
    	wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>');
    */

    Thanks again for the plugin. Works perfectly. I need these for a controlled classroom instruction where each student will have a unique theme they are editing, so there is no concern of one person editing a theme that another WP site is using.

    @jroakes Thanks for the code. It almost works. The themes link shows up, but I get the following error.

    Fatal error: Cannot redeclare _add_themes_utility_editor() (previously declared in /Volumes/staging/test_site/wp-content/plugins/theme-editor.php:44) in /Volumes/staging/test_site/wp-content/plugins/theme-editor.php on line 44

    In theme-editor.php I only commented out the following:

    if ( is_multisite() && ! is_network_admin() ) {
    		wp_redirect( network_admin_url( 'theme-editor.php' ) );
    		exit();
    		}

    I didn’t notice the closing comment tag, so I assumed it was only this block of code. Also switched to
    $themes=get_allowed_themes();

    Thanks in advance.

    Thread Starter jrue

    (@jrue)

    I figured it out finally. If anyone else has this issue, here is what I had to change:

    query_posts( array('category__in' => array($front_category_to_use), 'category__not_in' => array($front_featured_category_to_use) ) );

    This query_posts no longer resulted in posts. Instead, I had to use the taxonomy parameters which became the following:

    $cptaxquery['tax_query'] = array(
    		array(
    				'taxonomy' => 'category',
    				'terms' => array($front_category_to_use),
    				'field' => 'id',
    				'operator' => 'IN'
    		),
    		array(
    				'taxonomy' => 'category',
    				'terms' => array($front_featured_category_to_use),
    				'field' => 'id',
    				'operator' => 'NOT IN'
    		)
    );

    If anyone is stuck on this, here is the codex documentation on taxonomy. It doesn’t make it clear why this works in 3.1 as oppose to the older method.

    Thread Starter jrue

    (@jrue)

    For those who might be wondering, it was an error in the custom theme we wrote that would break the upgrade and end up corrupting our database.

    Before you upgrade to 3.1, it’s best to switch to the TwentyTen built-in theme, then run the upgrade. You can switch back after upgrading.

Viewing 7 replies - 1 through 7 (of 7 total)