professor99
Forum Replies Created
-
The discussion for the forks are here in the WPUF WordPress support forum (as you have seen) generally connected to the problems they are addressing due to the need for feedback. This is unlikely to change.
I do ask for people experiencing problems with my fork to reply on the fork page as it’s one I automatically receive replies and it helps others that may be experiencing the same problem.
Most of our discussions are open and here in the forum with heavy details and code passed though emails (as the WordPress moderator likes it short sharp and sweet).
Hi gpsake.
You probably know this already but have some info that may be useful to you and others.
Done a bit more investigation of what is really going on and have noted the differences between WordPress 3.4.2 and 3.5.1.
Basically WordPress 3.5.1 uses a new “Insert Media” interface for posts. This uses it’s new wp.media interface and that’s what creates our problem.
For both WordPress 3.4.2 and 3.5.1 the WPUF Rich Text editor option results in wp_editor being called which in turn calls the function wp-admin/includes/class-wp-editor.php:editor(). This in turn invokes the action ‘media_buttons’ which results in the function wp-admin/includes/media.php:media_buttons() being called.
From here on WordPress 3.4.2 and 3.5.1 differ.
For WordPress 3.4.2 the following excerpt shows wp-admin/includes/media.php:media_buttons() calling get_upload_iframe_src(..) which for WPUF results in the link wp-admin/media-upload.php?post_id=0 being added to the “Upload/Insert” button. This results in the attachment not being added to the Add/Edit Post Form.
wp-admin/includes/media.php ============================= function media_buttons($editor_id = 'content') { $context = apply_filters('media_buttons_context', __('Upload/Insert %s')); $img = '<img src="' . esc_url( admin_url( 'images/media-button.png?ver=20111005' ) ) . '" width="15" height="15" />'; echo '<a href="' . esc_url( get_upload_iframe_src() ) . '" class="thickbox add_media" id="' . esc_attr( $editor_id ) . '-add_media" title="' . esc_attr__( 'Add Media' ) . '" onclick="return false;">' . sprintf( $context, $img ) . '</a>'; } add_action( 'media_buttons', 'media_buttons' ); ... function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) { global $post_ID; /** Set to new post id by edit-form-advanced.php. Null for WPUF Add/Edit Post **/ if ( empty( $post_id ) ) /** Null for WPUF Add/Edit Post **/ $post_id = $post_ID; /** For $post_id = null => (int)$post_id = 0 **/ $upload_iframe_src = add_query_arg( 'post_id', (int) $post_id, admin_url('media-upload.php') ); if ( $type && 'media' != $type ) $upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src); if ( ! empty( $tab ) ) $upload_iframe_src = add_query_arg('tab', $tab, $upload_iframe_src); $upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src); return add_query_arg('TB_iframe', true, $upload_iframe_src); }For WordPress 3.5.1 the following excerpt shows wp-admin/includes/media.php:media_buttons() calling wp_enqueue_media(..). However at the beginning of media_buttons() it calls get_post() which gets the loop page which for WPUF is either the Add or Edit page with the shortcodes. This is the cause of our problems with WordPress 3.5.1.
wp-admin/includes/media.php =========================== /** * Adds the media button to the editor * * @since 2.5.0 * * @param string $editor_id */ function media_buttons($editor_id = 'content') { $post = get_post(); /** Gets the loop page. For WPUF this is the pages with the Add/Edit shortcodes **/ if ( ! $post && ! empty( $GLOBALS['post_ID'] ) ) $post = $GLOBALS['post_ID']; wp_enqueue_media( array( 'post' => $post ) ); ... } add_action( 'media_buttons', 'media_buttons' );The possible workarounds are numerous.
1. Add a custom editor (like you have done)
2. Replace the media_buttons action
3. Use the media_view_settings filter in the function wp-includes/media.php:wp_enqueue_media() to set the settings as desired for WPUF. This is probably the easiest option.
4. Use a filter or action further down the call stack to achieve the desired result.Below is the relevant excerpt from wp-includes/media.php:wp_enqueue_media()
wp-includes/media.php ====================== function wp_enqueue_media( $args = array() ) { ... $post = null; if ( isset( $args['post'] ) ) { $post = get_post( $args['post'] ); $settings['post'] = array( 'id' => $post->ID, 'nonce' => wp_create_nonce( 'update-post_' . $post->ID ), ); if ( current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' ) ) { $featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true ); $settings['post']['featuredImageId'] = $featured_image_id ? $featured_image_id : -1; } } ... $settings = apply_filters( 'media_view_settings', $settings, $post ); $strings = apply_filters( 'media_view_strings', $strings, $post ); $strings['settings'] = $settings; wp_localize_script( 'media-views', '_wpMediaViewsL10n', $strings ); ...Ultimately this is a WordPress bug as attachments shouldn’t be linked to the post till the user has pressed the “Insert Post/Page” button. I am probably putting in a WordPress trac bug report on this.
For gpsake I am posting you my complete function trace so you can see what’s going on.
Cheers
The ProfessorStarted to have a bigger look at this.
Just for the moment looking at the dual insert problem that results in the upload being attached to the add_post or edit_post page.
Can confirm it’s a WordPress 3.5.1 problem.
It doesn’t occur with WordPress 3.4.2 (At least with my development version).
What’s happening is that the rich editor executes the following lines depending on the editor chosen:
Rich Text(full)
wp_editor( $description, 'new-post-desc', array('textarea_name' => 'wpuf_post_content', 'editor_class' => 'requiredField', 'teeny' => false, 'textarea_rows' => 8) );Rich Text(tiny)
wp_editor( $description, 'new-post-desc', array('textarea_name' => 'wpuf_post_content', 'editor_class' => 'requiredField', 'teeny' => true, 'textarea_rows' => 8) );wp_editor is the default WordPress editor which uses TinyMCE.
On clicking the Add Media button this brings up the plupload (the add-on used to upload/insert media) interface.
If your only adding a previous file already in the media library then you wont have a problem.
However if you choose to upload media then that media will be added as an attachment to the Edit Post or Add Post page. This happens straight after the upload whether you insert the post or not.
This is a WordPress 3.5.1 bug as it’s totally different behaviour from WordPress 3.4.2 and is undesirable for many reasons.
So in summary this is a WordPress 3.5.1 bug. It is not a WPUF bug.
Workaround for the moment is not to use WordPress 3.5.1 if you need this feature.
In the meanwhile me and gpspake will try to find a better workaround.
I will also look at submitting a WordPress trac bug report as I’m sure other plugins will have this problem as well.
To WPChina,
To save yourself some work you could also use the WordPress “Permalink Settings” option to set all permalinks to a default of your own choosing
%home%/wp-admin/options-permalink.php
rajun are you using WordPress 3.5.1?
The only thing that I can think of in WPUF that may be causing your problem is the option ‘Admin area access’. Try disabling this to see if it solves your problem.
Im thinking $wp_admin_bar->remove_menu(‘wp-logo’) removes the admin bar for the duration of your session hence why it persists despite the deactivation of WPUF.
I do a similar thing but without problems as follows. Try this and see if it fixes your problem.
global $user_login; get_currentuserinfo(); /* Hide admin bar for non-admins */ if ( $user_login != 'admin' ) { add_filter( 'show_admin_bar', '__return_false' ); }To hardcode it without providing an option in the admin pages all you have to do is filter the $content in submit_post() in both the files wpuf_add_post.php and wpuf_edit_post.php. For the background look at the WordPress documentation on shortcodes.
I haven’t heard of this before. Please post the code you are using to do this in functions.php and we might be able to see what is causing it.
Strange the problem persists after deactivating WPUF. This would point to another plugin causing this problem so I would deactivate all other plugins first to see if this fixes the problem.Hi WPChina
There are currently 3 forks of WPUF happening.
Tareq (the originator) is working on a new version that updates the customization features and uses an entirely new interface that makes customization a breeze and adds the capability of multiple customized forms. This isn’t yet up on the net.
gpspake has also done a fork that looks at a few things.
We are all collaborating and we currently are of the opinion that the current custom fields implementation complicates things too much and Tareqs new customization methodology addresses this. So we are considering breaking things into two and having a basic version ( without custom fields that satisfies most users and is easy to use), and a Pro version (that allows complete customisation and multiple forms).
Edit wpuf_edit_user.php and change wpuf_user_edit_profile_form() to show_form().
Fixed this a while back in the development version
Edit wpuf_edit_user.php and change wpuf_user_edit_profile_form() to show_form().
Fixed this a while back in the development version
Don’t have this problem myself but Im using WordPress 3.4.2. Is this just a WordPress 3.5.1 problem? Is it a problem with everybody that’s using WordPress 3.5.1?
You need to edit the file wpuf_add_post.php as mentioned above. Find the submit_post() function and add the following parameter ‘post_name’ (set appropriately) to the my_post array which is passed to the WordPress function wp_insert_post().
Thanks for telling me why you needed it. amax2222 wanted to change the permalink too as you noticed above but failed to reply when I asked why.
Do you have the search plugin Relevanssi installed? We have had very similiar problems with this
There are a couple of functions calls by the array construction in wpuf_settings_fields(). The thief is hiding in wpuf_list_users(). He is only a petty thief with a penchant for pinching milliseconds as shown above. Without my cache this is called for each option so it adds up. However it only adds up to 50ms which is nothing unless your a penny pinching miser :).
PS The WordPress plugin “Debug Bar” and it’s accompanying plugin “Debug Bar Console” are a great way of monitoring SQL queries. Just add define(‘SAVEQUERIES’, true); to your wp-config.php file and it will show you all your SQL queries along with the function call stack for each. Makes tracking problems like this a cinch.