using get_option to add a different js

You had an extra ( before get_option and the if statement syntax was wrong. Here is the revised code: add_action(‘wp_footer’,’isotope_vpl_set_style’); function isotope_vpl_set_style() { $style = get_option(‘damien_style’); if($style == “isotope”) { include(“inc/myfile.js”); } }

How to redirect to action on custom page within admin section

Get the url of a specific admin page (e.g. the settings page (options-general.php)): admin_url( ‘options-general.php’ ) Codex admin_url() Adding query arguments to an url: $params = array( ‘page’ => $_REQUEST[‘page’], ‘action’ => ‘edit’, ‘rls_element’ => $item[‘rls_name’] ); $url = add_query_arg( $params, $org_url ); Codex add_query_arg() Put a and b together: $params = array( ‘page’ => … Read more

Get the link text

You can use posts custom fields to store a custom continue reading text for each post, and then use that value in the_content_more_link filter. For example you might have a custom field with meta key of continue_reading to enable users to specify the custom Read More text, and use that value like: add_filter(‘the_content_more_link’, ‘ad_contiue_reading_text’,10,2); function … Read more

Proper way to hook wp_get_attachment_url

Hook wp_get_attachment_link for this purpose. Here is an example of how to do it – function attachment_link_filter( $content, $post_id, $size, $permalink ) {       // Only do this if we’re getting the file URL     if (! $permalink) {         // This returns an array of (url, width, height)         $image = wp_get_attachment_image_src( $post_id, ‘large’ );         $new_content = … Read more

Customize multisite site creation with user data

To create a basic plugin, add a directory in wp-content/plugin, then put a php file in it with the required header, and that’s it. Now, here is how to use the action : add_action( ‘wpmu_new_blog’, ‘user16975_customize_blog’, 10, 6); function user16975_customize_blog($blog_id, $user_id, $domain, $path, $site_id, $meta ){ // do not forget to select the correct blog … Read more

Generating User(s) with Settings API

You are using add_settings_field wrong: the function sl_wp_create_user is being passed as $args (and you probably don’t need any args), and it should be the sanitize callback for register_settings. Make the input like: function sl_render_users_input() { echo ‘<input id=”num_users[value]” name=”num_users[value]” type=”input” value=”” />’; } And the sanitize function: function sl_wp_create_user( $input ) { if( isset( … Read more