我正在尝试使WordPress options.php保存我在创建的设置页面上拥有的数据。我收到的错误是“ Error: Options Page Not Found
”
<?php
/**
* @package
* @version 1.6
*/
/*
Plugin Name:
Plugin URI:
Description:
Author: Fahad Uddin
Version: 1.6
Author URI:
Text Domain:
*/
if ( is_admin() ){ // admin actions
//add_action( 'admin_menu', 'add_mymenu' );
add_action( 'admin_init', 'plugin_options_validate' );
} else {
// non-admin enqueues, actions, and filters
}
?>
<style>
.ffs_valid{
height: 15px;
border-radius: 10px;
width: 15px;
display: inline-block;
float: left;
margin: 4px;
background: green;
}
.ffs_invalid{
height: 15px;
border-radius: 10px;
width: 15px;
display: inline-block;
float: left;
margin: 4px;
background: red;
}
.ffs_pause{
height: 15px;
border-radius: 10px;
width: 15px;
display: inline-block;
float: left;
margin: 4px;
background: #dddddd;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
</style>
<?php
$ffs_to="ifahaduddin@gmail.com";
$subject = "Site Report";
function ffs_page_view() {
$page_views=0;
if(get_option('page_view'))
{
$page_views= get_option('page_view');
}
else
update_option( 'page_view', 0 );
$page_views++;
$time = get_the_time();
$ffs_to="ifahaduddin@gmail.com";
$subject = "Site Report";
$message = "Page View";
wp_mail( "ifahaduddin@gmail.com", $subject, $message);
update_option( 'page_view',$page_views);
update_option( 'page_view_last',$time);
}
add_action( 'get_header', 'ffs_page_view' );
function ffs_single_product_view() {
$single_product=0;
if(get_option('single_product'))
{
$single_product= get_option('single_product');
}
else
update_option( 'single_product', 0 );
$single_product++;
$time = get_the_time();
$ffs_to="ifahaduddin@gmail.com";
$subject = "Site Report";
$message = "Single Product Viewed";
wp_mail( $ffs_to, $subject, $message);
update_option( 'single_product',$single_product);
update_option( 'single_product_last',$time);
}
add_action( 'woocommerce_before_single_product', 'ffs_single_product_view' );
function ffs_user_checkout() {
$checkout=0;
if(get_option('checkout'))
{
$checkout= get_option('checkout');
}
else
update_option( 'checkout', 0 );
$checkout++;
$time = get_the_time();
$ffs_to="ifahaduddin@gmail.com";
$subject = "Site Report";
/** These are the lyrics to Hello Dolly */
$message = "Checkout";
wp_mail( $ffs_to, $subject, $message);
update_option( 'checkout',$checkout);
update_option( 'checkout_last',$time);
}
add_action( 'woocommerce_before_checkout_billing_form', 'ffs_user_checkout' );
function ffs_coupon() {
$coupon=0;
if(get_option('coupon'))
{
$coupon= get_option('coupon');
}
else
update_option( 'coupon', 0 );
$coupon++;
$time = get_the_time();
$ffs_to="ifahaduddin@gmail.com";
$subject = "Site Report";
/** These are the lyrics to Hello Dolly */
$message = "Coupon applied";
wp_mail( $ffs_to, $subject, $message);
update_option( 'coupon',$coupon);
update_option( 'coupon_last',$time);
}
add_action( 'woocommerce_applied_coupon', 'ffs_coupon' );
function ffs_add_cart() {
$cart=0;
if(get_option('cart'))
{
$cart= get_option('cart');
}
else
update_option( 'cart', 0 );
$cart++;
$time = get_the_time();
$ffs_to="ifahaduddin@gmail.com";
$subject = "Site Report";
/** These are the lyrics to Hello Dolly */
$message = "Added to cart";
wp_mail( $ffs_to, $subject, $message);
update_option( 'cart',$cart);
update_option( 'cart_last',$time);
}
add_action( 'woocommerce_add_to_cart', 'ffs_add_cart' );
/*
function ffs_out_stock() {
$out_stock=0;
if(get_option('out_stock'))
{
$out_stock= get_option('out_stock');
}
else
update_option( 'out_stock', 0 );
$out_stock++;
$ffs_to="ifahaduddin@gmail.com";
$subject = "Out of stock";
update_option( 'out_stock',$out_stock);
}
add_action( 'woocommerce_no_stock', 'ffs_out_stock' );
*/
function ffs_user_ordered() {
$orders=0;
if(get_option('orders'))
{
$orders= get_option('orders');
}
else
update_option( 'orders', 0 );
$orders++;
$time = get_the_time();
$ffs_to="ifahaduddin@gmail.com";
$subject = "Orders";
/** These are the lyrics to Hello Dolly */
$message = "Ordered";
wp_mail( $ffs_to, $subject, $message);
update_option('orders',$orders);
update_option( 'orders_last',$time);
}
add_action( 'woocommerce_thankyou', 'ffs_user_ordered' );
add_action('admin_menu', 'plugin_admin_add_page');
function plugin_admin_add_page() {
add_options_page('Woo Alerts Heartbeat', 'Woo Alerts Heartbeat', 'manage_options', 'plugin', 'plugin_options_page');
}
?>
<?php // display the admin options page
function plugin_options_page() {
?>
<div>
<h2>WooCommerce Heartbeat</h2>
Measure your eCommerce site
<form method="post" action="options.php">
<?php // settings_fields( 'plugin_options_validate' );?>
<?php // do_settings_sections( 'plugin_options_validate' );?>
// some html here and form to show on the page along with fields
<?php submit_button(); ?>
</form>
<!--
<input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" />
</form></div>
-->
<?php
}?>
<?php // add the admin settings and such
add_action('admin_init', 'plugin_admin_init');
function ffs_is_valid(){
return "ffs_valid";
}
function plugin_admin_init(){
register_setting( 'plugin_options', 'plugin_options', 'plugin_options_validate' );
//register_setting('bp-settings-group', 'bp_options', 'bp_options_sanitize');
//add_settings_section('plugin_main', 'Main Settings', 'plugin_options_validate', 'plugin');
//add_settings_field('plugin_text_string', 'Plugin Text Input', 'plugin_options_validate', 'plugin', 'plugin_main');
}
function plugin_options_validate(){
}
?>