Forum Replies Created

Viewing 15 replies - 31 through 45 (of 56 total)
  • Thread Starter Brayne

    (@brayne)

    bump

    Thread Starter Brayne

    (@brayne)

    I see that the codex recommends ‘init’. Just curious as to why some folks would use ‘template_redirect’ or ‘wp_head’ instead?

    Also, I’ve seen some plugin authors use 2 different action calls, 1. to register the script and 2. to enqueue. Isn’t it more efficient to take care of both in the same action call?

    @virgild

    function my_init() {
      if (!is_admin()) {
        wp_enqueue_script('the_js', plugins_url('/my_javascript.js',__FILE__) );
      }
    }
    add_action('init', 'my_init');

    This works for me to keep the script on the front end.

    I needed to add some scripts and css to the users profile page and used this code and thought I’d share in case someone else needs clarification…

    This registers a javascript and css file and uses these files on the user’s profile page and only loads on the user’s profile page.

    add_action('admin_init','my_cool_options');
    add_action('admin_print_scripts-profile.php', 'my_cool_styles');
    
    function my_cool_options() {
    		wp_register_script( 'mycoolscript', getContentURL() . '/my_cool.js' );
    		wp_register_style( 'mycoolstyle', getContentURL() . '/my_cool.css' );
    	}
    
    function my_cool_styles() {
            wp_enqueue_script( 'mycoolscript' );
            wp_enqueue_style( 'mycoolstyle' );
    	}
    
    function getContentURL() {
    		$mupluginsurl = WP_CONTENT_URL."/mu-plugins";
    		return ($_SERVER['HTTPS'] != "on") ? $mupluginsurl : str_replace("http", "https", $mupluginsurl);
    	}

    I used a custom function for calling the mu-plugins directory as this is where I place the files for a multi-site environment.

    Hope this helps someone.

    Thread Starter Brayne

    (@brayne)

    I made a dupe entry… sorry

    Hey jobmeer,

    be sure to read what bigbadboy was writing…. check the code with a “regular” user compared to an “administrator”

    This code works for both…..bigbadboy… you want to test it and let me know?? I tried this in said plugin and in functions.php and works in both….I was utilizing this parameter – $a[“plugins”] = “safari,inlinepopups,wordpress”;
    And it was causing it to not work with a regular subscriber… Also some of the above code uses hard coding the javascript file tiny_mce.js and it would take sooo long for the page to load this is the best solution I have found…

    if ( (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/user-edit.php')) || (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/profile.php'))) {
    	add_action('admin_head', 'add_tinymce');
    	}
    
    	remove_filter('pre_user_description', 'wp_filter_kses');
    	add_filter('pre_user_description', 'wpautop');
    
    function add_tinymce() {
    
    if (function_exists('wp_tiny_mce')) {	
    
      wp_enqueue_script('editor');  // This is the key to make it work...
      do_action('admin_print_scripts'); // This prints it in the proper place in the <head>
    
    		add_filter( 'teeny_mce_before_init', create_function( '$a', '
    			$a["theme"] = "advanced";
    			$a["skin"] = "wp_theme";
    			$a["height"] = "420";
    			$a["width"] = "400";
    			$a["onpageload"] = "";
    			$a["mode"] = "exact";
    			$a["elements"] = "description";
    			return $a;' ) );
    		wp_tiny_mce( true );
    	}
    }

    UPDATE – Working on it….. Realized this is a pretty lame solution if it only works for admins…. ;(.

    OK…. got weird…. I can guess that there was something going on with load order and changing from functions.php to the plugin has affected this..This can be changed in the action calls but it seems to be working out now…

    I did the same thing as bigbadboy and works just fine… All operations work as they should in FF, Safari, Opera on Mac. FF, Safari, IE7 on PC….IE6 however wont show the text in the Biographical Info field when tinyMCE is added… I blame IE6… It IS in the source code…just like bigbadboy wrote… but now not showing in that field when using IE6…unfortunately there is still 1 out 5 people using this browser so… I will still kick the tires on this..

    alexleonard is absolutely correct…. I didn’t pay attention to the comment made about using the plugin -> profiler. I was not using it. I installed it and took a look and made this change to the file profiler.php…

    At Line #464 I changed this….

    $output .= "<h3>About Me</h3>";
      $output .= "$user_description";

    To this…

    $output .= "<h3>About Me</h3>";
      $user_description = html_entity_decode($user_description);
      $output .= "$user_description";

    I have not notified the author because if he wanted to add this feature he would need to check a condition if using tinymce and such… You can limit the html allowed by making limits in tinymce but for now, making this change in profiler, the html will be read properly….

    I’ve been working on this extensively over the last 24 hours…. I have it working great. This is for WP vs 2.7 only…. and this is the scaled down version that is used in “press this”

    This goes in your functions.php file in your theme….I’m going to release an updated plugin for this feature later today…

    I found that the key is putting these 2 function calls in place….

    wp_enqueue_script(‘editor’);
    do_action(‘admin_print_scripts’);

    if ( (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/user-edit.php')) || (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/profile.php'))) {
    	add_action('admin_head', 'add_tinymce');
    	}
    
    	remove_filter('pre_user_description', 'wp_filter_kses');
    	add_filter('pre_user_description', 'wpautop');
    
    function add_tinymce() {
    
    if (function_exists('wp_tiny_mce')) {	
    
    	wp_enqueue_script('editor');
    	do_action('admin_print_scripts');
    
    		add_filter( 'teeny_mce_before_init', create_function( '$a', '
    			$a["theme"] = "advanced";
    			$a["skin"] = "wp_theme";
    			$a["height"] = "420";
    			$a["width"] = "400";
    			$a["onpageload"] = "";
    			$a["mode"] = "exact";
    			$a["elements"] = "description";
    			$a["editor_selector"] = "mceEditor";
    			$a["plugins"] = "safari,inlinepopups,wordpress";
    			$a["apply_source_formatting"] = "1";
    			$a["accessibility_focus"] = "1";
    			return $a;' ) );
    
    		wp_tiny_mce( true );
    	}
    }

    I have the same need. I wanted to put the tinymce in the member profile. I found I only needed the mini editor version that is used in quick edit…. I put this in my functions.php file in my active theme.

    if ( (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/user-edit.php')) || (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/profile.php'))) {
    	add_action('admin_head', 'add_tinymce');
    }
    
    remove_filter('pre_user_description', 'wp_filter_kses');
    add_filter('pre_user_description', 'wpautop');
    
    function add_tinymce() {
    
    if (function_exists('wp_tiny_mce')) {	
    
    		add_filter( 'teeny_mce_before_init', create_function( '$a', '$a["width"] = "440"; $a["height"] = "400"; $a["onpageload"] = ""; $a["mode"] = "exact"; $a["elements"] = "description"; $a["editor_selector"] = "mceEditor"; return $a;' ) );
    		wp_tiny_mce( true );
    
    	}
    }

    the big difference is where the code reads “mode” I set it to “exact” instead of “texareas” and then I had to add to the array set $a[“elements”] = “description”; where description is the id of the textarea for the user profile textarea…

    I hope this helps….

    Thread Starter Brayne

    (@brayne)

    Even More persistence pays off….. Has everything in the world already been done before?

    http://jumping-duck.com/wordpress/

    This plugin allows different roles at point of registration.

    Thread Starter Brayne

    (@brayne)

    So I helped myself…..persistence is a virtue.

    F.Y.I. for anyone looking for something similar…. you can control user data at registration by tapping into the wp_insert_user($userdata) function located in registration.php

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