WordPress use PHP & JavaScript in Widgets

Resolve adding the following code to the WordPress theme function.php file. HIGHLY recommend creating a child theme and using functions.php from that theme.

add_filter('widget_text','execute_php',100);
function execute_php($html){
     if(strpos($html,"<"."?php")!==false){
          ob_start();
          eval("?".">".$html);
          $html=ob_get_contents();
          ob_end_clean();
     }
     return $html;
}

To enable shortcodes in the Text and Custom HTML widget, add this code to your theme functions.php :

add_filter('widget_text','do_shortcode',10);

Learn how to use a plugin to create a child theme automatically here.

No code experience or just want to install yet another WordPress plugin, try PHP Code Widget.