Is wp-app.php or wp-apps.php needed for WordPress?

But if they’re needed by WP I don’t want to compromise site functions. Those are not Core files. It is possible that a plugin has added the files legitimately but the behavior described suggests a hack. Recovering from hacks is off-topic here though, as it usually requires hands-on server access and is often very localized.

Add filter multiple times using only one master function

Use a use statement: add_filter( ‘single_template’, function ( $template ) use ( $name ) { Or just pass all templates at once, and create just one function: add_filter( ‘single_template’, function ( $file ) use ( $templates ) { global $post; if ( in_array ( $post->post_type, $templates ) ) return __DIR__ . “/{$post->post_type}.php”; return $file; });

Get my site session in wordpress?

WordPress doesn’t use PHP session ($_SESSION). If you want to use it you need to do at your own. For example: add_action(‘init’, ‘wpse_session_start’, 1); function wpse_session_start() { if(!session_id()) { session_start(); } } But, if you want is to get the user id of the current user, you can use get_current_user_id(): <?php $user_ID = get_current_user_id(); ?>

Including all post id’s of a custom post type into an array

Save yourself a loop with get_posts and ‘fields’ => ‘ids’. // Default Query function do_query($args = null) { $default_args = array( ‘numberposts’ => -1, ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’, ‘fields’ => ‘ids’, ); if (null !== $args && !empty($args)) $args = array_merge($default_args, $args); else $args = $default_args; return get_posts($args); } // Customize Query $post_ids … Read more

Conditional Javascript based on WP Version

You can do this with the function get_bloginfo(). There is a special paramater called version that retrieves the wordpress version from the $wp_version variable set in wp-includes/version.php. So you could do something like this function register_jquery_wp_version() { global $wp_version; if ( $wp_version >= 3.8 ) { // register and enqueue jquery A }elseif( $wp_version >= … Read more

How can I call specific function if requested URL is not found?

Simply use template_redirect filter to perform check on request you get in wordpress. add_filter(‘template_redirect’, ‘my_404_override’ ); function my_404_override() { global $wp_query; if (!$wp_query->post) { // Check if any post is found. If not its 404. status_header( 200 ); $wp_query->is_404=false; // Create post object $my_post = array( ‘post_title’ => ‘My post’, ‘post_content’ => ‘This is my … Read more

Ajax contact form return 0

Your javascript is missing an action parameter with the data: $.post(action, { name: $(‘#name’).val(), email: $(‘#email’).val(), phone: $(‘#phone’).val(), subject: $(‘#subject’).val(), comments: $(‘#comments’).val(), verify: $(‘#verify’).val(), action: ‘ajaxContacForm’ // <– added action here }, function(data){ document.getElementById(‘message’).innerHTML = data; $(‘#message’).slideDown(‘slow’); $(‘#contactform img.loader’).fadeOut(‘slow’,function(){$(this).remove()}); $(‘#submit’).removeAttr(‘disabled’); if(data.match(‘success’) != null) $(‘#contactform’).slideUp(‘slow’); } );