brunodario
Forum Replies Created
-
Forum: Plugins
In reply to: [WP-Filebase Download Manager] Error WordPress – File not found!Here’s what i’ve realized so far in my case, with the lattest version of the plugin and WP 4.3.1:
- If the file has a name with spaces, it will trough the not found error.
- If the file name is separates by “-” then it also giver not found error (I.E: my-file-name.pdf)
- It only works with the browser OR batch uploader, not working with flash uploader
- Renaming the files with underscores solved it for me (my_file_name.pdf works, if not uploaded by the flash uploader)
Forum: Plugins
In reply to: [WooCommerce] Change coupon description messageI’m not totaly sure if this is what u want, but woocommerce has a couple of filters that allow to change coupon messages:
Filter “woocommerce_coupon_message” will change the “Coupon code applied successfully.” message
“woocommerce_cart_totals_coupon_label” will change “Coupon” label in “Cart Totals” box on Cart page and “Your Order” box on checkout.
Forum: Plugins
In reply to: [SharePress] works with custom post ?Hi, yes it works, i have this plugin running on several custom post types websites, the admin console lets you choose in wich CTP you gonna have the share box.
Forum: Hacks
In reply to: How to make a direct link to a specific website when clicking on the post?What you need to do is
-
Add a new custom field on your post screens, so you can enter the desired external URL to the image trough the “new post” screen.
Retrieve the value of this custom field whenever you want to
1- Add a metabox
The code bellow will add a custom field name “image url” at your post page, you should add it to the “functions.php” file:function myplugin_add_meta_box() { $tela = 'post'; add_meta_box( 'myplugin_sectionid', __( 'Cidade / Estado', 'myplugin_textdomain' ), 'myplugin_meta_box_callback', $tela ); } add_action( 'add_meta_boxes', 'myplugin_add_meta_box' ); /** * Prints the box content. * * @param WP_Post $post The object for the current post/page. */ function myplugin_meta_box_callback( $post ) { // Add an nonce field so we can check for it later. wp_nonce_field( 'myplugin_meta_box', 'myplugin_meta_box_nonce' ); /* * Use get_post_meta() to retrieve an existing value * from the database and use the value for the form. */ $value = get_post_meta( $post->ID, '_my_meta_value_key', true ); echo '<label for="myplugin_new_field">'; _e( 'Link to apply to the image', 'myplugin_textdomain' ); echo '</label> '; echo '<input type="text" id="myplugin_new_field" name="myplugin_new_field" value="' . esc_attr( $value ) . '" size="25" />'; } /** * When the post is saved, saves our custom data. * * @param int $post_id The ID of the post being saved. */ function myplugin_save_meta_box_data( $post_id ) { /* * We need to verify this came from our screen and with proper authorization, * because the save_post action can be triggered at other times. */ // Check if our nonce is set. if ( ! isset( $_POST['myplugin_meta_box_nonce'] ) ) { return; } // Verify that the nonce is valid. if ( ! wp_verify_nonce( $_POST['myplugin_meta_box_nonce'], 'myplugin_meta_box' ) ) { return; } // If this is an autosave, our form has not been submitted, so we don't want to do anything. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Check the user's permissions. if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_id ) ) { return; } } else { if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } } /* OK, it's safe for us to save the data now. */ // Make sure that it is set. if ( ! isset( $_POST['myplugin_new_field'] ) ) { return; } // Sanitize user input. $my_data = sanitize_text_field( $_POST['myplugin_new_field'] ); // Update the meta field in the database. update_post_meta( $post_id, '_my_meta_value_key', $my_data ); } add_action( 'save_post', 'myplugin_save_meta_box_data' );
After this you should see a field in your post admin page that says “Link to apply to the image”.
2- Retrieve the value of the field anywhere
To create a link with the value you can simply include the following code:
Get the value:
$customurl = get_post_meta( $id, '_my_meta_value_key', true );
Output it as a link:
<a href="<?php echo $customurl; ?>"><the code of the image here></a>