What’s the earliest point I can get the queried object ID?

A more compact and WordPress-ish way, using url_to_postid(): function wpmp_switcher_exclusions_init() { $pid = url_to_postid( home_url( add_query_arg( array() ) ) ); if ( (int) $pid > 0 && get_post_meta( $pid, ‘_wp_page_template’, TRUE ) === ‘my-responsive-template.php’ ) { remove_action(‘init’, ‘wpmp_switcher_init’); remove_action(‘admin_menu’, ‘wpmp_switcher_admin_menu’); remove_action(‘wp_footer’, ‘wpmp_switcher_wp_footer’); remove_filter(‘stylesheet’, ‘wpmp_switcher_stylesheet’); remove_filter(‘template’, ‘wpmp_switcher_template’); remove_filter(‘option_home’, ‘wpmp_switcher_option_home_siteurl’); remove_filter(‘option_siteurl’, ‘wpmp_switcher_option_home_siteurl’); } } add_action( ‘setup_theme’, ‘wpmp_switcher_exclusions_init’ … Read more

How do I conditionally enqueue script for CPT single post type with plugin?

Make sure your code runs in wp_enqueue_scripts action hook. Also checkout your script handle ‘owl.carousel.js’. In wp_script_is(), it is not the same than in the 2 later functions in which you enter it as ‘owl.carousel.min.js’. add_action( ‘wp_enqueue_scripts’, ‘enqueue_properties_scripts’ ); function enqueue_properties_scripts() { if ( ‘properties’ === get_post_type() ) { if ( wp_script_is( ‘owl.carousel.min.js’, ‘enqueued’ ) … Read more

Upload file to remote storage

Two options: Hook into ‘wp_handle_upload’, a filter provided by the function wp_handle_upload() in wp-admin/includes/file.php: apply_filters( ‘wp_handle_upload’, array( ‘file’ => $new_file, ‘url’ => $url, ‘type’ => $type ), ‘upload’ ) Replace the new file URI with your remote URI. The function wp_insert_attachment() in wp-includes/post.php offers two actions: do_action(‘edit_attachment’, $post_ID); do_action(‘add_attachment’, $post_ID); You can get the attachment … Read more

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