Skip to content

Instantly share code, notes, and snippets.

@mujahidi
Last active July 13, 2022 16:00
Show Gist options
  • Save mujahidi/2b07af78ec8b80460d8f3d94f7915144 to your computer and use it in GitHub Desktop.
Save mujahidi/2b07af78ec8b80460d8f3d94f7915144 to your computer and use it in GitHub Desktop.
Add new fields to WC admin Page Setup
<?php
// Admin -> WC -> Settings -> Advanced -> Page Setup
add_filter( 'woocommerce_settings_pages' , 'add_new_woocommerce_settings_pages' );
function add_new_woocommerce_settings_pages( $settings ){
$new_pages = array();
foreach( $settings as $s ){
if( $s['id'] == 'advanced_page_options' ){
$new_pages[] = array(
'title' => __( 'Registration page', 'woocommerce' ),
'id' => 'woocommerce_registration_page',
'type' => 'single_select_page_with_search',
'default' => '',
'class' => 'wc-page-search',
'css' => 'min-width:300px;',
'args' => array(
'exclude' =>
array(
wc_get_page_id( 'checkout' ),
wc_get_page_id( 'myaccount' ),
wc_get_page_id( 'cart' ),
),
),
'desc_tip' => false,
'autoload' => false,
);
$new_pages[] = array(
'title' => __( 'Reports page', 'woocommerce' ),
'id' => 'woocommerce_reports_page',
'desc' => 'Page contents: <br>[efp_reports]',
'type' => 'single_select_page_with_search',
'default' => '',
'class' => 'wc-page-search',
'css' => 'min-width:300px;',
'args' => array(
'exclude' =>
array(
wc_get_page_id( 'checkout' ),
wc_get_page_id( 'myaccount' ),
wc_get_page_id( 'cart' ),
),
),
'desc_tip' => true,
'autoload' => false,
);
break;
}
}
// move newly added array elements to different position inside array
array_splice( $settings, 1, 0, $new_pages );
return $settings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment