Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter davewise

    (@davewise)

    Oh, btw, here is how you execute the function by calling it in the place where you want it to occur.

    <?php
    	echo $siteplugins[rand(0, $totalPlugins -1)]['function']();
    ?>

    Just in case 😉

    D.

    Thread Starter davewise

    (@davewise)

    Never mind it was working, I was just looking in the wrong place for the answer, one of those “Staring at the screen to long” moments, as soon as I woke up I spotted it.

    For anyone that’s interested it’s for selecting multiple category ID’s to pass to external plugins, I am just adapting a tile theme to insert available plugins (or widgets) into the space where a post would be. So not only do you get posts as part of the index tiles, you can now get ad’s (via AdRotate and recent category news from Special Recent Posts) randomly added to the mix. The theme option is basically so you can supply a random category (selected) to the recent posts call. I build an array of known available (i.e.. active) plugins, build the parameters and functions and store the calling function in an array. Then at user selected intervals insert a plugin rather than a post.

    Not very exciting and I’m sure it’s been done time and time again, but hey, might as well give it a go.

    Using the above options builds a Select statement as follows :

    <select id="categories" name="options[categories][]" multiple="multiple" size="10" style="width: 100px;" >
    
    <?php
    	$settings = get_option( 'options', $options );
    
    	$arg  = array(
    	'type'                     => 'post',
    	'child_of'                 => 0,
    	'parent'                   => '',
    	'orderby'                  => 'name',
    	'order'                    => 'ASC',
    	'hide_empty'               => 0,
    	'taxonomy'                 => 'category');
    
    	$siteCategories = get_categories($arg);
    
    	foreach ($siteCategories as $siteCat) {
    		$siteCatID = $siteCat->cat_ID;
    		$siteCatName = $siteCat->cat_name;
    		if (in_array($siteCatID, $settings['categories']))
    			echo "<option value='${siteCatID}' selected='selected'>$siteCatName</option>";
    		else
    			echo "<option value='${siteCatID}'>$siteCatName</option>";
    	}
    ?>
    </select>

    So now, when I insert a “Special Posts” Plugin I can supply random categories from the list selected rather than just the default.

    If you’re interested in the actual code that builds an active plugin list with associated arrays and functions, here it is.

    // Lets start by using the wordpress built in functions to find out what we have
    	// and what's active that we recognise.
    
    	// Our returning array will contain a numerical index, a name and the code needed
    	// to make it work.
    
    	// These are the plugins we currently know about and know how to insert them via
    	// PHP into the main html output.
    
    	$specialposts = array('name' => 'Special Recent Posts', 'function' => create_function('', '$settings = get_option("infinity_options"); $totalCats = count($settings["categories"]); $randCat = $settings["categories"][rand(0, $totalCats - 1)]; $randName = get_cat_name($randCat); $args = array("srp_widget_title" => "$randName Recent Articles", "srp_number_post_option" => "3", "srp_filter_cat_option" => $randCat); special_recent_posts($args);'));
    	$wp125 = array('name' => 'WP125', 'function' => create_function('', 'echo "<center>"; wp125_write_ads(); echo "</center>"; '));
    	$adrotate = array ('name' => 'AdRotate', 'function' => create_function('', 'echo adrotate_group("1");'));
    
    	$knownplugins = array ($specialposts, $wp125, $adrotate);
    	$knownpluginsno = count($knownplugins);
    
    	include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    	$allplugins = get_plugins();	
    
    	$activeplugins = 0;
    
    	foreach ($allplugins as $plugin => $pdata) {
    
    		// Check all plugins against our list of known plugins
    		for ($i=0; $i<($knownpluginsno); $i++) {
    
    			if ((strcmp($pdata['Name'], $knownplugins[$i]['name']) == 0) and is_plugin_active($plugin)) {
    				$siteplugins[$activeplugins++] = $knownplugins[$i];
    			}
    		}
    
    	}
    
    	return $siteplugins;

    Anyway, I hope that helps add inspiration to someone, somewhere, some time 😉

    Onwards and upwards as they say.

    D.

    Thread Starter davewise

    (@davewise)

    Right, final update.

    Hosting company updated their systems and managed to screw the permissions on /tmp. After my asking them to check the MySQL error logs it was found to be a /tmp permissions problem.

    As soon as the permissions were corrected the categories came straight back.

    WordPress really should give the errors it encounters like this to the admin panel.

    Anyway, its now all working again.

    D.

    Thread Starter davewise

    (@davewise)

    I think it is something screwy with the way the hosting company provide the service, it has to be, it’s the only thing left that I cannot actually see. I have sent in a request to check the MySQL error logs (I don’t have visibility of them). It’s got to be something stupid, I think we’ve now exhausted all the clever stuff LOL!

    I’ll keep this thread posted on any replies/resolutions.

    D.

    Thread Starter davewise

    (@davewise)

    wp-admin and wp-includes have both been replaced with zero effect.

    Process for replacing

    > wget wordpress.org/latest.zip
    > unzip latest.zip
    > mv wordpress vanilla-wordpress
    > cd working wordpress root
    > mv wp-admin /outside web root
    > mv wp-includes /outside web root
    > mv /vanilla-wordpress/wp-admin /web root
    > mv /vanilla-wordpress/wp-includes /web root

    Both directories have basically been completely replaced with the default directories included with the default distribution of wordpress 3.4.1

    Still the issue exists.

    Thread Starter davewise

    (@davewise)

    Just in case it helps here is the Filesystem usage:

    Filesystem Size Used Avail Use% Mounted on
    /dev/sda5 7.8G 1.3G 6.2G 17% /
    /dev/sda1 122M 15M 101M 13% /boot
    /dev/sda6 186G 130G 47G 74% /home
    /dev/sda7 996M 34M 911M 4% /tmp
    /dev/sda2 20G 5.8G 13G 32% /usr
    /dev/sda3 9.7G 4.0G 5.3G 43% /var

    I’ve also found a video on YouTube of the same issue but with no resolution:

    Youtube video

    Thread Starter davewise

    (@davewise)

    No updates, no changes, not even a post added since the last. Hence only just noticing the issue :/ I am totally stumped, I didn’t particularly want to offer the advice “re-install everything” as it feels a bit of a copout so to speak. I had checked for malware through google, but I’ve just run that link supplied (Thanks! one to remember!) and all clean.

    Security report (No threats found):
    Blacklisted: No
    Malware: No
    Malicious javascript: No
    Malicious iFrames: No
    Drive-By Downloads: No
    Anomaly detection: No
    IE-only attacks: No
    Suspicious redirections: No
    Spam: No

    Seriously doing my noodle in, it just doesn’t make any sense.

    D.

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