SSL: How to make customizer images Protocol Relative in WordPress?

I think the simpler solution would be to create your own function: function get_theme_mod_img($mod_name){ return str_replace(array(‘http:’, ‘https:’), ”, get_theme_mod($mod_name)); } then just use it: <a href=”https://wordpress.stackexchange.com/questions/256864/<?php echo esc_url(get_theme_mod(“slide_one_link’)); ?>”><img src=”<?php echo esc_url( get_theme_mod_img( ‘slide_img_upload_one’ ) ); ?>” alt=”<?php echo get_theme_mod( ‘slide_title_1’ ); ?>” /></a> there is another solution that involve filters as you can see … Read more

Restrict WordPress File Type Uploads by User Type

There is a syntax error in your conditional: current_user_can(‘administrator’) The input value is wrapped in ‘ ’, which should be wrapped in ‘ ‘ instead. Right now, because ‘administrator’ is neither a role nor capability, the above will always return a false value, therefore if(!current_user_can(‘administrator’)) will always return true, which will restrict the mime type … Read more

How to change “Publish” button text for specific page

I wanted to change the Publish button’s text in the Block Editor and came across this question. With the answers given it wasn’t changing the text. With the Gutenberg update, I realized it would have to be done with JavaScript. I found this response: Changing text within the Block Editor Which I applied in my … Read more

How can I use a video header that’s over 8MB?

The limit is enforced by _validate_header_video method, registered as validation callback on respective Customizer setting. There is a filter that allows you to hook into the process and manipulate those arguments: add_filter( ‘customize_dynamic_setting_args’, function ( $args, $id ) { if ( ‘header_video’ === $id ) { // change $args[‘validate_callback’] } return $args; }, 10, 2 … Read more

“upload_mimes” filter not working. Need to allow WOFF and WOFF2

I see a correct implementation at https://wordpress.stackexchange.com/a/323226/24756. Technically, you need to pass down the extension down to filter wp_check_filetype_and_ext as well. And for WOFF/WOFF2, I’d suggest using the following format: $mimes[‘woff’] = ‘font/woff|application/font-woff|application/x-font-woff|application/octet-stream’; $mimes[‘woff2’] = ‘font/woff2|application/octet-stream|font/x-woff2’; For .webp, it can simply be image/webp. Hope it helps.

How to disable the suffix “-scaled” which is being added at the end of each uploaded image?

How to disable this behaviour? Add this to your functions.php: add_filter( ‘big_image_size_threshold’, ‘__return_false’ ); How does it work? When a new image is uploaded, WordPress will detect if it is a “big” image by checking if its height or width exceeds the big_image threshold. The default threshold value is 2560px, filterable with the new big_image_size_threshold … Read more

Front-end Image Upload with Preview – Is this Possible in WP?

Just add this scripts in header <script src=”http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js”></script> <script> var blank=”http://upload.wikimedia.org/wikipedia/commons/c/c0/Blank.gif”; function readURL(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { $(‘#img_prev’) .attr(‘src’, e.target.result) .height(100); }; reader.readAsDataURL(input.files[0]); } else { var img = input.value; $(‘#img_prev’).attr(‘src’,img).height(200); } $(“#x”).show().css(“margin-right”,”10px”); } $(document).ready(function() { $(“#x”).click(function() { $(“#img_prev”).attr(“src”,blank); $(“#x”).hide(); }); }); </script> … Read more

Get attachments by user

Use a custom query for this. $user_id = 1; $the_query = new WP_Query( array( ‘post_type’ => ‘attachment’, ‘post_status’ => ‘inherit’, ‘author’ => $user_id) ); if ( $the_query->have_posts() ) while ( $the_query->have_posts() ) : $the_query->the_post(); the_title(); endwhile; This will show all the attachment titles for user with user id 1. You can use get_the_ID() in the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)