Checkbox default unchecked - php

For my Wordpress plugin option page I want to use checkboxes to set the options. I'm using this code to add it to the option page and it works well. Except that I want the checkboxes default set to unchecked. How do I do this?
public function id_number_callback()
{
printf(
'<input id="%1$s" name="cus_func_option[%1$s]" type="checkbox" %2$s" />',
'add_image_dimesions',
checked( isset( $this->options['add_image_dimesions'] ), true, false )
);
Edit: The full code I want to use is this
class MySettingsPage
{
/**
* Holds the values to be used in the fields callbacks
*/
private $options;
/**
* Start up
*/
public function __construct()
{
add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
add_action( 'admin_init', array( $this, 'page_init' ) );
}
/**
* Add options page
*/
public function add_plugin_page()
{
// This page will be under "Settings"
add_options_page(
'Settings Admin',
'Custom functions',
'manage_options',
'cus-func-admin',
array( $this, 'create_admin_page' )
);
}
/**
* Options page callback
*/
public function create_admin_page()
{
// Set class property
$this->options = get_option( 'cus_func_option' );
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>Custom Functions</h2>
<form method="post" action="options.php">
<?php
// This prints out all hidden setting fields
settings_fields( 'cus_func_group' );
do_settings_sections( 'cus-func-admin' );
submit_button();
?>
</form>
</div>
<?php
}
/**
* Register and add settings
*/
public function page_init()
{
register_setting(
'cus_func_group', // Option group
'cus_func_option', // Option name
array( $this, 'sanitize' ) // Sanitize
);
add_settings_section(
'setting_section_id', // ID
'Which Custom Functions do you want to use?', // Title
array( $this, 'print_section_info' ), // Callback
'cus-func-admin' // Page
);
add_settings_field(
'add_image_dimesions', // ID
'Add image dimesions to the Media Page', // Title
array( $this, 'id_number_callback' ), // Callback
'cus-func-admin', // Page
'setting_section_id' // Section
);
add_settings_field(
'title',
'Title',
array( $this, 'title_callback' ),
'cus-func-admin',
'setting_section_id'
);
}
/**
* Sanitize each setting field as needed
*
* #param array $input Contains all settings fields as array keys
*/
public function sanitize( $input )
{
$new_input = array();
if( isset( $input['add_image_dimesions'] ) )
$new_input['add_image_dimesions'] = absint( $input['add_image_dimesions'] );
if( isset( $input['title'] ) )
$new_input['title'] = sanitize_text_field( $input['title'] );
return $new_input;
}
/**
* Print the Section text
*/
public function print_section_info()
{
print 'Pick your Custom Functions below:';
}
/**
* Get the settings option array and print one of its values
*/
public function id_number_callback()
{
printf(
'<input id="%1$s" name="cus_func_option[%1$s]" type="checkbox" %2$s" />',
'add_image_dimesions',
checked( isset( $this->options['add_image_dimesions'] ), true, false )
);
}
/**
* Get the settings option array and print one of its values
*/
public function title_callback()
{
printf(
'<input id="%1$s" name="cus_func_option[%1$s]" type="checkbox" %2$s />',
'title',
checked( isset( $this->options['title'] ), true, false )
);
}
}
if( is_admin() )
$my_settings_page = new MySettingsPage();

Refer to the WordPress Documentation for checked
What is the value of isset( $this->options['add_image_dimesions'] ) in your code?
This is what is determining whether it's checked or not.

If you want the checkbox to always be unchecked when the page is loaded, then you can just remove the second printf token, %2$2, and the second argument to printf, checked( isset( $this->options['add_image_dimesions'] ), true, false ), which will give you this:
public function id_number_callback()
{
printf(
'<input id="%1$s" name="cus_func_option[%1$s]" type="checkbox" />',
'add_image_dimesions'
);

Related

Include custom template file issue in Woocommerce my account page

I am trying to add an include a template file located in my active child theme:
childtheme/woocommerce/myaccount/order-a-kit.php
The function use also echo "Hello World" which is displayed successfully, but not the included php template file.
I have tried those:
include($_SERVER['DOCUMENT_ROOT']."twentyseventeen-child/woocommerce/myaccount/order-a-kit.php");
include($get_stylesheet_directory_uri()."twentyseventeen-child/woocommerce/myaccount/order-a-kit.php");
include 'twentyseventeen-child/woocommerce/myaccount/order-a-kit.php';
The content of the order-a-kit.php is super simple, I am just trying to include that file:
<?php
?>
<div>
<p>
Look at me
</p>
</div>
This is my function.php section and everything is doing as it should except the include function towards the bottom:
add_filter( 'woocommerce_account_menu_items', 'add_my_menu_items', 99, 1 );
function add_my_menu_items( $items ) {
$my_items = array(
// endpoint => label
'order-a-kit' => __( 'Order A Kit', 'woocommerce'),
'orders' => __( 'Order History', 'my_plugin' ),
);
$my_items = array_slice( $items, 0, 1, true ) +
$my_items +
array_slice( $items, 1, count( $items ), true );
return $my_items;
}
//adding custom endpoint
function my_custom_endpoints() {
add_rewrite_endpoint( 'order-a-kit', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'my_custom_endpoints' );
function my_custom_query_vars( $vars ) {
$vars[] = 'order-a-kit';
return $vars;
}
add_filter( 'query_vars', 'my_custom_query_vars', 0 );
function my_custom_flush_rewrite_rules() {
flush_rewrite_rules();
}
add_action( 'wp_loaded', 'my_custom_flush_rewrite_rules' );
//including custom endpoint
function my_custom_endpoint_content() {
include 'twentyseventeen-child/woocommerce/myaccount/order-a-kit.php';
echo '<p>Hello World!</p>';
}
add_action( 'woocommerce_account_order-a-kit_endpoint', 'my_custom_endpoint_content' );
?>
Any help is greatly appreciated.
As the "woocommerce" folder is inside your theme as the function.php file you just need to use:
include 'woocommerce/myaccount/order-a-kit.php';
See this related answer: WooCommerce: Adding custom template to customer account pages
Try this
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'woocommerce/myaccount/order-a-kit.php';
You can add this code to your theme's function.php:
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* #var string
*/
public static $endpoint = 'Your Desired Link';
/**
* Plugin actions.
*/
public function __construct() {
// Actions used to insert a new endpoint in the WordPress.
add_action( 'init', array( $this, 'add_endpoints' ) );
add_filter( 'query_vars', array( $this, 'add_query_vars' ), 0 );
// Change the My Accout page title.
add_filter( 'the_title', array( $this, 'endpoint_title' ) );
// Insering your new tab/page into the My Account page.
add_filter( 'woocommerce_account_menu_items', array( $this, 'new_menu_items' ) );
add_action( 'woocommerce_account_' . self::$endpoint . '_endpoint', array( $this, 'endpoint_content' ) );
}
/**
* Register new endpoint to use inside My Account page.
*
* #see https://developer.wordpress.org/reference/functions/add_rewrite_endpoint/
*/
public function add_endpoints() {
add_rewrite_endpoint( self::$endpoint, EP_ROOT | EP_PAGES );
}
/**
* Add new query var.
*
* #param array $vars
* #return array
*/
public function add_query_vars( $vars ) {
$vars[] = self::$endpoint;
return $vars;
}
/**
* Set endpoint title.
*
* #param string $title
* #return string
*/
public function endpoint_title( $title ) {
global $wp_query;
$is_endpoint = isset( $wp_query->query_vars[ self::$endpoint ] );
if ( $is_endpoint && ! is_admin() && is_main_query() && in_the_loop() && is_account_page() ) {
// New page title.
$title = __( 'Your Item Name', 'woocommerce' );
remove_filter( 'the_title', array( $this, 'endpoint_title' ) );
}
return $title;
}
/**
* Insert the new endpoint into the My Account menu.
*
* #param array $items
* #return array
*/
public function new_menu_items( $items ) {
// Remove the logout menu item.
$logout = $items['customer-logout'];
unset( $items['customer-logout'] );
// Insert your custom endpoint.
$items[ self::$endpoint ] = __( 'Your Item Name', 'woocommerce' );
// Insert back the logout item.
$items['customer-logout'] = $logout;
return $items;
}
/**
* Endpoint HTML content.
*/
public function endpoint_content() {
//example include('woocommerce/myaccount/Your-File.php');
include('Path-To-Your-File.php');
}
/**
* Plugin install action.
* Flush rewrite rules to make our custom endpoint available.
*/
public static function install() {
flush_rewrite_rules();
}
}
new My_Custom_My_Account_Endpoint();
// Flush rewrite rules on plugin activation.
register_activation_hook( __FILE__, array( 'My_Custom_My_Account_Endpoint', 'install' ) );
You have to simply set "Your Desired Link"x1 and "Your Item Name"x2 and "Path-To-Your-File.php"x1 in this source.
If you don't know where is your theme's function.php:
1.Log in to the WordPress Admin interface
2.In the left sidebar, hover over Appearances, then click Theme Editor
3.In the right sidebar, click functions.php

on creating custom option page in wordpress

on creating custom field in option page for my wordpress theme it show some error on each input type text call_user_func() expects parameter 1 to be a valid callback,class 'MySettingsPage' does not have a method logo_callback() or social_callback() please suggest some solution
private $options;
public function __construct()
{
add_action( 'admin_menu', array( $this, 'bguru_register_options_page' ) );
add_action( 'admin_init', array( $this, 'bguru_register_settings' ) );
}
public function bguru_register_options_page()
{
// This page will be under "Settings"
add_theme_page('Business Guru Options',
'Theme Customizer',
'edit_theme_options',
'bguru-options',
array( $this, 'bguru_options_page')
);
}
public function bguru_options_page()
{
// Set class property
$this->options = get_option( 'bguru_logo' );
$this->options = get_option( 'bguru_vimeo' );
?>
<div class="wrap">
<?php screen_icon(); ?>
<h1>Business Guru Options</h1>
<form method="post" action="options.php">
<?php
// This prints out all hidden setting fields
settings_fields( 'defaultbg' );
do_settings_sections( 'defaultbg' );
submit_button();
?>
</form>
</div>
<?php
}
public function bguru_register_settings()
{
register_setting('defaultbg','bguru_logo', array( $this, 'sanitize' ) );
register_setting('defaultbg', 'bguru_vimeo', array( $this, 'sanitize' ));
add_settings_section(
'setting_section_id', // ID
'General',
array( $this, 'print_section_info' ), // Callback
'defaultbg' // Page
);
add_settings_field(
'bguru_logo', // ID
'Logo', // Title
array($this,'logo_callback()' ), // Callback
'defaultbg', // Page
'setting_section_id' // Section
);
add_settings_field(
'bguru_vimeo', // ID
'Vimeo', // Vimeo
array( $this, 'socialv_callback()' ), // Callback
'defaultbg', // Page
'setting_section_id' // Section
);
}
public function sanitize( $input )
{
$new_input = array();
if( isset( $input['bguru_logo'] ) )
$new_input['bguru_logo'] = sanitize_text_field( $input['bguru_logo'] );
if( isset( $input['bguru_vimeo'] ) )
$new_input['bguru_vimeo'] = sanitize_text_field( $input['bguru_vimeo'] );
return $new_input;
}
public function print_section_info()
{
print 'Enter your settings below:';
}
public function logo_callback()
{
printf(`enter code here`
'<input type="text" id="bguru_logo" size="50" name="bguru_logo" value="%s" />',
isset( $this->options['bguru_logo'] ) ? esc_attr( $this->options['bguru_logo']) : ''
);
}
public function socialv_callback()
{
printf(
'<input type="text" id="bguru_vimeo" size="50" name="bguru_vimeo" value="%s" />',
isset( $this->options['bguru_vimeo'] ) ? esc_attr( $this->options['bguru_vimeo']) : ''
);
}
}
if( is_admin() )
$my_settings_page = new MySettingsPage();
After Look Into Your Code, I think You need to remove () From array($this,'logo_callback()' ).
See below code, i have change & fixed:-
class MySettingsPage
{
private $options;
public function __construct()
{
add_action( 'admin_menu', array( $this, 'bguru_register_options_page' ) );
add_action( 'admin_init', array( $this, 'bguru_register_settings' ) );
}
public function bguru_register_options_page()
{
// This page will be under "Settings"
add_theme_page('Business Guru Options',
'Theme Customizer',
'edit_theme_options',
'bguru-options',
array( $this, 'bguru_options_page')
);
}
public function bguru_options_page()
{
// Set class property
$this->options['bguru_logo'] = get_option( 'bguru_logo' );
$this->options['bguru_vimeo'] = get_option( 'bguru_vimeo' );
?>
<div class="wrap">
<?php screen_icon(); ?>
<h1>Business Guru Options</h1>
<form method="post" action="options.php">
<?php
// This prints out all hidden setting fields
settings_fields( 'defaultbg' );
do_settings_sections( 'defaultbg' );
submit_button();
?>
</form>
</div>
<?php
}
public function bguru_register_settings()
{
register_setting('defaultbg','bguru_logo', array( $this, 'sanitize' ) );
register_setting('defaultbg', 'bguru_vimeo', array( $this, 'sanitize' ));
add_settings_section(
'setting_section_id', // ID
'General',
array( $this, 'print_section_info' ), // Callback
'defaultbg' // Page
);
add_settings_field(
'bguru_logo', // ID
'Logo', // Title
array($this,'logo_callback' ), // Callback
'defaultbg', // Page
'setting_section_id' // Section
);
add_settings_field(
'bguru_vimeo', // ID
'Vimeo', // Vimeo
array( $this, 'socialv_callback' ), // Callback
'defaultbg', // Page
'setting_section_id' // Section
);
}
public function sanitize( $input )
{
$new_input = array();
if( isset( $input['bguru_logo'] ) )
$new_input['bguru_logo'] = sanitize_text_field( $input['bguru_logo'] );
if( isset( $input['bguru_vimeo'] ) )
$new_input['bguru_vimeo'] = sanitize_text_field( $input['bguru_vimeo'] );
return $new_input;
}
public function print_section_info()
{
print 'Enter your settings below:';
}
public function logo_callback()
{
printf('<input type="text" id="bguru_logo" size="50" name="bguru_logo" value="%s" />',
isset( $this->options['bguru_logo'] ) ? esc_attr( $this->options['bguru_logo']) : ''
);
}
public function socialv_callback()
{
printf('<input type="text" id="bguru_vimeo" size="50" name="bguru_vimeo" value="%s" />',
isset( $this->options['bguru_vimeo'] ) ? esc_attr( $this->options['bguru_vimeo']) : ''
);
}
}
if( is_admin() )
$my_settings_page = new MySettingsPage();
Hope this will work for you.

WordPress option page not showing submitting value

I have to create an option page using array in my wordpress theme. after submitting all fill up information removed while i am using
var_dump( $this->options) show blank array(){}
I want when submitting option page form submit information show in the input box and i will get_option value in some variable so that i have to display the information in my theme.
<?php
class MySettingsPage
{
private $options;
public function __construct()
{
add_action( 'admin_menu', array( $this, 'bguru_register_options_page' ) );
add_action( 'admin_init', array( $this, 'bguru_register_settings' ) );
}
public function bguru_register_options_page()
{
// This page will be under "Settings"
add_theme_page('Business Guru Options',
'Theme Customizer',
'edit_theme_options',
'bguru-options',
array( $this, 'bguru_options_page')
);
}
public function bguru_options_page()
{
// Set class property
$bguru_logo = is_array( get_option( 'bguru_logo' ) ) ? get_option( 'bguru_logo' ) : array();
$bguru_vimeo = is_array( get_option( 'bguru_vimeo' ) ) ? get_option( 'bguru_vimeo' ) : array();
$this->options = array_merge( $bguru_logo, $bguru_vimeo);
var_dump($this->options);
?>
<div class="wrap">
<?php screen_icon(); ?>
<h1>Business Guru Options</h1>
<form method="post" action="options.php">
<?php
// This prints out all hidden setting fields
settings_fields( 'defaultbg' );
do_settings_sections( 'defaultbg' );
submit_button();
?>
</form>
</div>
<?php
}
public function bguru_register_settings()
{
register_setting('defaultbg','bguru_logo', array( $this, 'sanitize' ) );
register_setting('defaultbg', 'bguru_vimeo', array( $this, 'sanitize' ));
add_settings_section(
'setting_section_id', // ID
'General',
array( $this, 'print_section_info' ), // Callback
'defaultbg' // Page
);
add_settings_field(
'bguru_logo', // ID
'Logo', // Title
array($this,'logo_callback' ), // Callback
'defaultbg', // Page
'setting_section_id' // Section
);
add_settings_field(
'bguru_vimeo', // ID
'Vimeo', // Vimeo
array( $this, 'socialv_callback' ), // Callback
'defaultbg', // Page
'setting_section_id' // Section
);
}
public function sanitize( $input )
{
$new_input = array();
if( isset( $input['bguru_logo'] ) )
$new_input['bguru_logo'] = sanitize_text_field( $input['bguru_logo'] );
if( isset( $input['bguru_vimeo'] ) )
$new_input['bguru_vimeo'] = sanitize_text_field( $input['bguru_vimeo'] );
return $new_input;
}
public function print_section_info()
{
print 'Enter your settings below:';
}
public function logo_callback()
{
printf('<input type="text" id="bguru_logo" size="50" name="bguru_logo" value="%s" />',
isset( $this->options['bguru_logo'] ) ? esc_attr( $this->options['bguru_logo']) : ''
);
}
public function socialv_callback()
{
printf('<input type="text" id="bguru_vimeo" size="50" name="bguru_vimeo" value="%s" />',
isset( $this->options['bguru_vimeo'] ) ? esc_attr( $this->options['bguru_vimeo']) : ''
);
}
}
if( is_admin() )
$my_settings_page = new MySettingsPage();

PHP - If information exists in an array already, display that information instead

I have a Wordpress plugin settings page which uses the following plugin settings page:
<?php
class NewPlugin
{
private $options;
/**
* Start up
*/
public function __construct()
{
add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
add_action( 'admin_init', array( $this, 'page_init' ) );
}
/**
* Add options page
*/
public function add_plugin_page()
{
// This page will be under "Settings"
add_options_page(
'Settings Admin',
'New Plugin',
'manage_options',
'new-plugin-admin',
array( $this, 'create_admin_page' )
);
}
/**
* Options page callback
*/
public function create_admin_page()
{
// Set class property
$this->options = get_option( 'new_plugin_options' );
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>New Plugin Settings</h2>
<form method="post" action="options.php">
<?php
// This prints out all hidden setting fields
settings_fields( 'new_plugin_options_group' );
do_settings_sections( 'new-plugin-admin' );
submit_button();
?>
</form>
</div>
<?php
}
/**
* Register and add settings
*/
public function page_init()
{
register_setting(
'new_plugin_options_group', // Option group
'new_plugin_options', // Option name
array( $this, 'sanitize' ) // Sanitize
);
add_settings_section(
'setting_section_id', // ID
'Settings', // Title
array( $this, 'print_section_info' ), // Callback
'new-plugin-admin' // Page
);
add_settings_field(
'title',
'Title',
array( $this, 'title_callback' ),
'new-plugin-admin',
'setting_section_id'
);
add_settings_field(
'addresslineone',
'Address Line One',
array( $this, 'addresslineone_callback' ),
'new-plugin-admin',
'setting_section_id'
);
add_settings_field(
'addresslinetwo',
'Address Line Two',
array( $this, 'addresslinetwo_callback' ),
'new-plugin-admin',
'setting_section_id'
);
}
/**
* Sanitize each setting field as needed
*
* #param array $input Contains all settings fields as array keys
*/
public function sanitize( $input )
{
if( isset( $input['title'] ) )
$new_input['title'] = sanitize_text_field( $input['title'] );
if( isset( $input['addresslineone'] ) )
$new_input['addresslineone'] = sanitize_text_field( $input['addresslineone'] );
if( isset( $input['addresslinetwo'] ) )
$new_input['addresslinetwo'] = sanitize_text_field( $input['addresslinetwo'] );
return $new_input;
}
/**
* Print the Section text
*/
public function print_section_info()
{
print 'Enter your settings below:';
}
/**
* Get the settings option array and print one of its values
*/
public function title_callback()
{
printf(
'<input type="text" id="title" name="new_plugin_options[title]" value="%s" />',
isset( $this->options['title'] ) ? esc_attr( $this->options['title']) : ''
);
}
/**
* Get the settings option array and print one of its values
*/
public function addresslineone_callback()
{
printf(
'<input type="text" id="addresslineone" name="new_plugin_options[addresslineone]" value="%s" />',
isset( $this->options['addresslineone'] ) ? esc_attr( $this->options['addresslineone']) : ''
);
}
public function addresslinetwo_callback()
{
printf(
'<input type="text" id="addresslinetwo" name="new_plugin_options[addresslinetwo]" value="%s" />',
isset( $this->options['addresslinetwo'] ) ? esc_attr( $this->options['addresslinetwo']) : ''
);
}
}
if( is_admin() )
$new_plugin_settings = new NewPlugin();
I already had a widget where the details asked for are in an array "$instance". I am trying to write an if statement which asks if $instance exists, then convert the strings to the new array.. So far I have not had much luck. Can anyone point me in the right direction?
As there is not much information about the $instance variable, these functions should help depending on the condition to consider that a variable exists :
isset
empty
property_exists

Wordpress admin settings page - extracting array

I am looking at building a plugin with a admin settings page. Looking at the codex, I have the following code:
<?php
class MyNewPlugin
{
/**
* Holds the values to be used in the fields callbacks
*/
private $options;
/**
* Start up
*/
public function __construct()
{
add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
add_action( 'admin_init', array( $this, 'page_init' ) );
}
/**
* Add options page
*/
public function add_plugin_page()
{
// This page will be under "Settings"
add_options_page(
'Settings Admin',
'My New Plugin',
'manage_options',
'my-new-plugin-admin',
array( $this, 'create_admin_page' )
);
}
/**
* Options page callback
*/
public function create_admin_page()
{
// Set class property
$this->options = get_option( 'my_new_plugin_option' );
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>My New Plugin Settings</h2>
<form method="post" action="options.php">
<?php
// This prints out all hidden setting fields
settings_fields( 'my_new_plugin_option_group' );
do_settings_sections( 'my-new-plugin-admin' );
submit_button();
?>
</form>
</div>
<?php
}
/**
* Register and add settings
*/
public function page_init()
{
register_setting(
'my_new_plugin_option_group', // Option group
'my_new_plugin_option', // Option name
array( $this, 'sanitize' ) // Sanitize
);
add_settings_section(
'setting_section_id', // ID
'Settings', // Title
array( $this, 'print_section_info' ), // Callback
'my-new-plugin-admin' // Page
);
add_settings_field(
'title',
'Title',
array( $this, 'title_callback' ),
'my-new-plugin-admin',
'setting_section_id'
);
add_settings_field(
'addresslineone',
'Address Line One',
array( $this, 'addresslineone_callback' ),
'my-new-plugin-admin',
'setting_section_id'
);
add_settings_field(
'addresslinetwo',
'Address Line Two',
array( $this, 'addresslinetwo_callback' ),
'my-new-plugin-admin',
'setting_section_id'
);
}
/**
* Sanitize each setting field as needed
*
* #param array $input Contains all settings fields as array keys
*/
public function sanitize( $input )
{
if( isset( $input['title'] ) )
$new_input['title'] = sanitize_text_field( $input['title'] );
if( isset( $input['addresslineone'] ) )
$new_input['addresslineone'] = sanitize_text_field( $input['addresslineone'] );
if( isset( $input['addresslinetwo'] ) )
$new_input['addresslinetwo'] = sanitize_text_field( $input['addresslinetwo'] );
return $new_input;
}
/**
* Print the Section text
*/
public function print_section_info()
{
print 'Enter your settings below:';
}
/**
* Get the settings option array and print one of its values
*/
public function title_callback()
{
printf(
'<input type="text" id="title" name="my_new_plugin_option[title]" value="%s" />',
isset( $this->options['title'] ) ? esc_attr( $this->options['title']) : ''
);
}
/**
* Get the settings option array and print one of its values
*/
public function addresslineone_callback()
{
printf(
'<input type="text" id="addresslineone" name="my_new_plugin_option[addresslineone]" value="%s" />',
isset( $this->options['addresslineone'] ) ? esc_attr( $this->options['addresslineone']) : ''
);
}
public function addresslinetwo_callback()
{
printf(
'<input type="text" id="addresslinetwo" name="my_new_plugin_option[addresslinetwo]" value="%s" />',
isset( $this->options['addresslinetwo'] ) ? esc_attr( $this->options['addresslinetwo']) : ''
);
}
}
if( is_admin() )
$my_new_plugin_settings = new MyNewPlugin();
include_once "mynewpluginwidget.php";
A simple plugin to start off with, the user enters the settings on the setting page and it displays in the widget area (user has to add the widget where they want it to be).
The question is, how do I extract the settings and display them? I presume they are in the array $this, but cannot get them to display..

Categories