我已将我的短代码添加到Wordpress页面,除非登录帐户的人查看该页面,否则该短代码似乎不会运行。以下是我目前掌握的代码:
<?php
/*
Plugin Name: MGC
Description: A plugin to integrate software
Author: Mike Grossman
Version: 0.1
*/
require_once(dirname(__FILE__) . \'/aweber_api/aweber_api.php\');
require_once( dirname( __FILE__ ) . \'/wlm_api/class-api-methods.php\' );
require_once(dirname(__FILE__) . \'/wlm_api/wlmapiclass.php\');
$member_registration_results = array();
add_action(\'admin_menu\', \'mgc_plugin_setup_menu\'); //load menu bar on the admin panela and run the function
function mgc_plugin_setup_menu(){
add_menu_page( \'MGC Plugin Page\', \'MGC Plugin\', \'manage_options\', \'mgc-plugin\', \'mgc_page_output\');
}
function mgc_page_output(){
echo "MGC Plugin Activated!";
}
//Capture the $_POST data
function wpd_post_parse() {
$string = \'wp hook: \' . var_dump($_POST) . "\\r\\n";
$fileName = dirname(__FILE__) . \'/log.txt\';
file_put_contents($fileName, $string, FILE_APPEND | LOCK_EX);
}
function mgc_init(){
$htmlStr = \'Hello World!\' . "\\r\\n";
$fileName = dirname(__FILE__) . \'/log.txt\';
file_put_contents($fileName, $htmlStr, FILE_APPEND | LOCK_EX);
//do_action( \'wpd_post_parse\' );
}
//add_action( \'parse_request\', \'wpd_post_parse\' );
add_shortcode(\'mgc\',\'mgc_init\'); //put this shortcode [mgc] on page in Wordpress
?>