Admin plugin, how can I output a different content-type?

I’ve done this two ways: 1) – a csv export function – detect that special content type handling is required BEFORE wp outputs anything. add_action (‘plugins_loaded’, ‘amr_meta_handle_csv’); function amr_meta_handle_csv ($csv, $suffix=’csv’) { // chcek if there is a csv request on this page BEFORE we do anything else ? if (( isset ($_POST[‘csv’]) )) { … Read more

How to enable edit button in the theme’s customize UI?

I just had the same issue and with a little googling I found the following solution: // Add the selective part $wp_customize->selective_refresh->add_partial( ‘your_theme_second_logo’, array( ‘selector’ => ‘#yourID’, // You can also select a css class ) ); After you add the custom settings, you need to tell to WordPress what settings you want to manage … Read more

WordPress Admin is displaying Not Available

There are different reasons why this can happen. In your case I think it may be a security plugin that has changed the deafult login URL to something else. When I go to http://www.philenglish.com.cn/wp-login.php I get a 404 error, which is something such plugins also do: they make the default login URLs unavailable in an … Read more

admin-ajax returning 400 error when request is made with Fetch API

To make a working HTTP request with fetch API you have to do something like this. const form = new FormData(); form.append(‘action’, ‘make_appointment’); form.append(‘post_title’, ‘hola como estas’); const params = new URLSearchParams(form); fetch(ajaxSettings.ajaxurl, { method: ‘POST’, credentials: ‘same-origin’, headers: { ‘Content-Type’: ‘application/x-www-form-urlencoded’, ‘Cache-Control’: ‘no-cache’, }, body: params }).then(response => { return response.json(); }) .then(response => … Read more

How to make media upload private? [duplicate]

Searching this Stack, I can see two possible solutions for this question (not tested). One The answer is not fully developed, but can provide some insight. Restricting access to files within a specific folder Two How to Protect Uploads, if User is not Logged In? Frank Bueltge’s answer seems interesting but the code is quite … Read more

Using plural-only translation of register_post_status() in plugin

// Get the plural post status label $ps_status_label = $status->label_count; $submenu[$menu][] = array( sprintf( translate_nooped_plural( $ps_status_label, $ps_status_count ), $ps_status_count ), This should work as expected for the core translations. Now you need the textdomain, so lets search for the string you wish to translate foreach ( $GLOBALS[‘l10n’] as $domain => $data ) { if ( … Read more