How To Redirect To Another Page After Download

Hi
If you want to download file after submit form then use given below code.

$file ='pm-brochure.pdf';
force_download($file); // call function to download file
// FUNCTION TO FORCE A DOWNLOAD
function force_download($filename)
{
   $basename = basename($filename);
   $filedata = file_get_contents($filename);
 
   if ($filedata)
   {
   // THESE HEADERS ARE USED ON ALL BROWSERS
      header("Content-Type: application-x/force-download");
      header("Content-Disposition: attachment; filename=\"$basename\"");
      header("Content-length: ".(string)(strlen($filedata)));
      header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");
      header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
   // THIS HEADER MUST BE OMITTED FOR IE 6
      if (FALSE === strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE 6'))
      {
         header("Cache-Control: no-cache, must-revalidate");
      }
   // THIS IS THE LAST HEADER
      header("Pragma: no-cache");
   // FLUSH THE HEADERS TO THE BROWSER
      flush();
   // CAPTURE THE FILE IN THE OUTPUT BUFFERS - WILL BE FLUSHED AT SCRIPT END
      ob_start();
      echo $filedata;
   }
}

Tagged with: , , ,
Posted in Drupal, HTML, Joomla, PHP, Wordpress

How to stop multi submit jQuery validation form?

Hi,

If your form are going to submit multi time on a single submit action then don’t worry.

You can fix this problem by using inbuilt jquery validation event submitHandler.

Tagged with: , , ,
Posted in HTML, Joomla, JQuery, Magento, PHP, Wordpress

How to add custom menu item in admin bar or in toolbar?

By using hooks & filters of wordpress, we can use add new custom menu item under admin bar. there are no need to use any plugin.

admin_bar_menu hooks is used to add the admin bar menu.

To add new item menu in admin bar, you will require to add given below code into your theme function.php file.

if(!function_exists('add_custom_admin_bar_item')):
add_action( 'admin_bar_menu', 'add_custom_admin_bar_item', 500 );
function add_custom_admin_bar_item($wp_admin_bar) {
    if ( ! current_user_can( 'manage_options' ) ) {
        return;
    }
    $admin_bar->add_menu( array(
        'id'    => 'custom-menu',
        'parent' => null,
        'group'  => null,
        'title' => 'My Menu', //you can use img tag with image link. it will show the image icon Instead of the title.
        'href'  => admin_url('admin.php?page=custom-page'),
        'meta' => [
            'title' => __( 'Menu Menu', 'textdomain' ), //This title will show on hover
        ]
    ) );
}
endif;

To add multi level admin bar menu item or want to add a new menu item under exsting parent admin bar menu item them you will required to define it’s parent menu item id. As per given above code, there are parent menu id is “custom-menu”. If we want to add a sub menu under “custom-menu” then we will need to define it’s parent id to “custom-menu”

Tagged with: , ,
Posted in Wordpress

How to create sub menu and option page of custom post type?

To add the submenu item under any custom post type page, First you will need to create a submenu item under custom post type menu section and then need to create a option page.

To add a new Sub-menu to WordPress Administration, use the add_submenu_page() function.

add_submenu_page( string $parent_slug, string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '', int $position = null )

add_submenu_page() function takes a capability which will be used to determine whether or not a page is included in the menu.

Parameters #Parameters

$parent_slug (string) (Required) The slug name for the parent menu (or the file name of a standard WordPress admin page).

$page_title (string) (Required) The text to be displayed in the title tags of the page when the menu is selected.

$menu_title (string) (Required) The text to be used for the menu.

$capability (string) (Required) The capability required for this menu to be displayed to the user.

$menu_slug (string) (Required) The slug name to refer to this menu by. Should be unique for this menu and only include lowercase alphanumeric, dashes, and underscores characters to be compatible with sanitize_key().

$function (callable) (Optional) The function to be called to output the content for this page.

Default value: ”

$position (int) (Optional) The position in the menu order this item should appear.

Default value: null


Example:

For a example, we have already created a gallery custom post type and now we are going to create settings page of gallery.

To add the submenu item under custom post type menu, we have need to add given below code in your theme function.php file

/*  Create new submenu item */
add_action('admin_menu', 'my_post_type_submenu');

function my_post_type_submenu()
{
add_submenu_page(
        'edit.php?post_type=ve_gallery',
        __( 'Settings', 'virtualemployee' ),
        __( 'Settings', 'virtualemployee' ),
        'manage_options',
        'gallery-options',
        'gallery_settings_page_callback'
    );

}

Click here to read more

Tagged with: , , ,
Posted in Wordpress

New block editor features and how to switch to old classic editor – WordPress 5.0

Disable wordpess 5.0 new editor without using any plugin .

Recently wordpres have released new version i.e WordPress5 with some major features. You can say that it’s the advance version of the wordpress. WordPress 5.0 is a bigger jump than recent major updates

Key Features of wordpress5
* New Block Editor
* New Default Theme: Twenty Nineteen

In new editor wordpress given an option to build your website without technical knowledge.

Block editor provided different types of block i.e paragraph, heading, preformatted text, quote, image, gallery, cover image, video, audio, columns with nested blocks, files, code, and more to show how content is displayed And Every block easily maneuverable with mouse or keyboard

Now lets come on main query i.e “How we can use use classic editor with wordpress5 without using any plugin?”. It’s just a two line code that will help you to remove the new “Block Editor” and rollback to classic editor.

You will need to add given below hooks filter into theme function.php file to remove new block editor

Click here to read more

Tagged with: , ,
Posted in Wordpress

How to create a permalink of custom post type with same slug as custom taxonomy?

Hello Everyone!

I hope you are doing well.

This time I am going to share one more useful knowledge to all wordpress developers who want to create a new custom url with same slug of custom taxonomy and custom post type.

I am going here to create a new custom post type “my_articles” with their custom taxonomy “my_article_term”. You can use your own custom post type name at place of “my_articles”.

Click here to read more

Tagged with: , , , , ,
Posted in Wordpress

Get flat 20% discount on wordpress best Social Share plugin

Hi There,

Get flat 20% discount on addons on the occasion of completing 3 Lakhs downloads of wordpress best social share plugin 

Video Demo : https://youtu.be/QUnxtCe95Ww

“Pay one time use lifetime!! “

Offer valid for limited period, so hurry up!!!!

Posted in Wordpress
Recent Posts
%d bloggers like this: