• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

My Monkey Do

A Log of Coding Solutions

  • Home
  • Web Hosts
  • Tools
  • About

php

IIS 7 PHP Write Permissions

June 15, 2011 by Webhead

Problem:

PHP is throwing errors saying it cannot find a directory when trying to upload a file.  This usually means PHP does not have permissions to create or modify files in that directory.

Solution:

I’m not sure why, but adding Modify and Write permissions for COMPUTERUsers group solves the problem.  Found the solution here: http://forums.iis.net/t/1153990.aspx

Filed Under: Coding Tagged With: iis, php

WordPress CMS Plugins

June 15, 2011 by Webhead

WordPress has tons of features, but most clients just need to edit pages and want a content management system.  I needed to get rid of all the fat.

Complicated Menus

To get rid of the menus on the dashboard for all roles except the admin place the following code in the functions.php of your theme.

function remove_menus () {
    global $menu;
    if (!(current_user_can('install_themes'))) {
        $restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
    }
    else {
        return;
    }
	end ($menu);
	while (prev($menu)){
		$value = explode(' ',$menu[key($menu)][0]);
		if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
	}
}
add_action('admin_menu', 'remove_menus');

Thanks to http://www.wprecipes.com/how-to-remove-menus-in-wordpress-dashboard

Redirected Login

A problem that arises from this is the dashboard is pretty much useless.  You can use this plugin to redirect a user to a specific page based on their role:  http://wordpress.org/extend/plugins/peters-login-redirect/

Easy TinyMCE adjustments

One plugin that makes this very simple:  http://wordpress.org/extend/plugins/tinymce-advanced/

 

Filed Under: Coding Tagged With: php, wordpress

Use the Same Arg in Sprintf

June 14, 2011 by Webhead

When using sprintf you can use the same argument  like so:

sprintf(“You want the %1$s? You can’t handle the %1$s!”, “truth”);

The %1$s means it will pull from the first argument.

Filed Under: Coding Tagged With: php

Creating an Instance of a PHP Class

May 15, 2011 by Webhead

Problem:

This works in PHP 5.3+:

$CLASS_NAME = 'TheName';

$class_instance = new $CLASS_NAME;

This doesn’t

define('CLASS_NAME', 'TheName');

$class_instance = new CLASS_NAME;

 

Workaround:

Use the way that works.  There are other limitations with using a variable to create a class.  Another way to create a class from a variable is by using:

$test = call_user_func(array($className, 'getInstance'));

 

Filed Under: Coding Tagged With: php

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 6
  • Go to page 7
  • Go to page 8

Primary Sidebar

Topics

apache apple block editor chrome cms css debug eCommerce embed firebug firefox git gmail goDaddy google hosting htaccess html html 5 IE crap image iPad iPhone javascript jquery linux localization mac os x ms sql mysql open source optimize php php 5.3 responsive rest api seo svg tinymce woocommerce wordpress wpengine xss yii youtube




Categories

  • Coding
  • Off the Shelf
  • Plugins
  • Random Thoughts
  • Server Stuff
  • Tools