blueshark
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Custom role with add_roleI followed your suggestions and created an init function, which is hooked to ‘load-themes.php’. Now the function is called only when you switch themes. So I guess this is the correct place, since add_role is not always called.
But still I had the same issue, so I printed the privileges of the new role with
$custom_editor = get_role( 'custom_editor' ); $custom_editor->add_cap( 'edit_theme_options' ); print_r($custom_editor);
The capbability ‘edit_theme_options’ was not included. Then I realised, that a comma was missing at the end of my initial code. So instead of
'upload_files' => true,
there was'upload_files' => true
. And now after this hassle it works as expected. ??Thank you for your help.
Forum: Developing with WordPress
In reply to: Custom role with add_roleThanks for your reply.
I was guessing, that something according to the order of calling my functions is not correct. I would totally agree with you, if both ways would not work. Since extending an existing role with ‘add_cap’ works fine, some doubts are remaining.
Can you please provide the whole function, where you placed ‘add_role’. I want to doulbe check if I put the call for ‘add_role’ at the correct position.
Forum: Hacks
In reply to: Print Button -> print.cssI do have a print stylesheet. But I prefer also a preview, so that the user can see what he is printing. So I want to reload the page with the print stylesheet. This stylesheet is triggered with the ->print<- option.
Forum: Hacks
In reply to: How to echo "BTW: Don’t use
echo " <link rel=\"stylesheet\" href=\""; echo $available_themes[$current_theme]; echo " \" type= \"text/css \" media=\"screen\" > " ;
to enqueue your style. Use the function wp_enqueue_style instead.
Forum: Fixing WordPress
In reply to: 2.9.2: Weird behaviour with commentsHey Guys,
I was so despreate, that I have choosen the brute force method, and so I reinstalled the latest wordpress version and restored my backup.
And now, its unbelievable, everything works fine. I have no clue what happened.Forum: Fixing WordPress
In reply to: 2.9.2: Weird behaviour with commentsI could isolate the error a litte bit.
Responsible are the functions get_post in wp-includes/post.php
function &get_post(&$post, $output = OBJECT, $filter = 'raw') { global $wpdb; $null = null; if ( empty($post) ) { if ( isset($GLOBALS['post']) ) $_post = & $GLOBALS['post']; else return $null; } elseif ( is_object($post) && empty($post->filter) ) { _get_post_ancestors($post); $_post = sanitize_post($post, 'raw'); wp_cache_add($post->ID, $_post, 'posts'); } else { if ( is_object($post) ) $post = $post->ID; $post = (int) $post; if ( ! $_post = wp_cache_get($post, 'posts') ) { $_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post)); if ( ! $_post ) return $null; _get_post_ancestors($_post); $_post = sanitize_post($_post, 'raw'); wp_cache_add($_post->ID, $_post, 'posts'); } } if ($filter != 'raw') $_post = sanitize_post($_post, $filter); if ( $output == OBJECT ) { return $_post; } elseif ( $output == ARRAY_A ) { $__post = get_object_vars($_post); return $__post; } elseif ( $output == ARRAY_N ) { $__post = array_values(get_object_vars($_post)); return $__post; } else { return $_post; } }
and the function comments_open in wp-includes/comment-template.php.
function comments_open( $post_id=NULL ) { $_post = get_post($post_id); $open = ( 'open' == $_post->comment_status ); return apply_filters( 'comments_open', $open, $post_id ); }
With printf-debuging I found out, that in the function get_post, the return value $_post is an object and in comments_open, where it is called, it is no longer an opject but just a number. The number is the id of the current comment.
So I guess, there is rather an issue with my php set-up rather with wordpress. Unfortunately, I have no clue, where and how I can fix this.
Anyone any idea?
Forum: Fixing WordPress
In reply to: 2.9.2: Weird behaviour with commentsYes, I deactivated all plugins and tried also several themes, including the default themes from wordpress. But I thought, that this includes also an error, that is why I installed a new theme. Furthermore, I did not use any commets related plugins.
So I guess, since no one else seems to have this problem, that something with my database is broken?
Forum: Plugins
In reply to: Admin – Create Pages – Theme ButtonsAfter going though a lot of code, I think modifying either the function wp_insert_post in wp-includes/post.php or wp_write_post in wp-admin/includes/post.php for generating an image button will do the job.
However, I don’t want to touch these files, to keep the update mechanism simple. Is there another oportunity to overload one of the two functions without touchting the mentioned files?
Forum: Everything else WordPress
In reply to: Understanding Database DesignThank you for the links ??
Forum: Plugins
In reply to: wp_mail with attachmentConfused by the Codex-Page(https://codex.www.ads-software.com/Function_Reference/wp_mail), where the usage did not mention attachments at all, I thought it is not possible. But a look into the file pluggable.php offered me the whole usage of wp_mail. So it is possible with just:
<?php wp_mail($to, $subject, $message, $headers = '', $attachments = array() ); ?>