enhance admin

3 plugins to enhance admin columns in wordpress

  • https://wordpress.org/plugins/codepress-admin-columns/
  • https://wordpress.org/plugins/media-library-assistant/
  • https://wordpress.org/plugins/admin-management-xtended/

Delete taxonomy terms of a specific level or superior

I had produced a code that automatically creates taxonomy terms when visitors visit my web site : i found out that thousands of terms had been created , cloaking my database. only solution was to use the following code to automatically delete terms of level >1

 

set_time_limit(0);
 error_reporting(E_ERROR | E_WARNING | E_PARSE);

  function myErrorHandler($errno, $errstr, $errfile, $errline) {
    echo "<br>error" . $errstr . $errfile;
    return true;
  }
if (!strstr($_SERVER["SERVER_NAME"],"cadiou")) exit();
  //$old_error_handler = set_error_handler("myErrorHandler");
require( './wp-load.php' ); 

$tax_name = 'gamme';
$terms = get_terms( $tax_name );
function sort_terms_hierarchicaly(Array &$cats, Array &$into, $parentId = 0, $level=0)
{
    foreach ($cats as $i => $cat) {
        if ($cat->parent == $parentId) {
            $into[$cat->term_id] = $cat;
			echo"<br> $level ".str_repeat(" - " ,$level) . $cat->term_id . " : " .  $cat->slug;
			if ($level>1) wp_delete_term($cat->term_id, "gamme");
            unset($cats[$i]);
        }
    }

    foreach ($into as $topCat) {
        $topCat->children = array();
        sort_terms_hierarchicaly($cats, $topCat->children, $topCat->term_id, $level++);
    }
}$categories = get_terms('gamme', array('hide_empty' => false));
$categoryHierarchy = array();
sort_terms_hierarchicaly($categories, $categoryHierarchy);

 

Woocommerce BACS GATEWAY : display bank account info on order page

default woocommerce order page suffers on major drawback, it does not display bank account info for customers who have chose to pay via BACS  (Bank Account Clearing System), more commonly known as direct bank/wire transfer. This payment method comes integrated within standard woocommerce plugin (more info). The bank account number can be configured in the payment config area of woocommerce, and it is displayed on the confirmation page. But not on the order page that the customer can view any time after the order. Here is a piece of code that displays specific bank transfer information  at the bottom of  the order display page :

 

add_action('woocommerce_view_order','po201407view_order');

function po201407view_order($order_id)
{
 echo $order_id;
 $order=new WC_Order( $order_id );
  if ( $order->payment_method !== 'bacs') return;
	//echo $order->payment_method_title;
	$bacs = new WC_Gateway_BACS();
	//print_r( $bacs->account_details);
	  $bacs->thankyou_page( $order_id);
}