有没有办法在define语句中使用变量;目前$wpdb->prefix
正常工作;但$useasprefix=$post->post_author
没有;它返回空,除非在这种情况下使用print_r($useasprefix=$post->post_author);
它返回1;理想情况下,表格的前缀与post_author
wp_cache_flush();
global $wpdb;
global $post;
$useasprefix=$post->post_author;
// Paths
define('Gocal_Plugin_AbsPath', str_replace('\\', '/', ABSPATH).'wp-content/plugins/go-cal/');
define('Gocal', WP_PLUGIN_URL.'/go-cal/');
// Tables
define('GOCAL_Set_table',$useasprefix .'_gocal_settings');
define('GOCAL_Cal_table',$useasprefix .'_gocal_calendars');
define('GOCAL_Day_table',$useasprefix .'_gocal_dopbs_days');
define('GOCAL_Res_table',$useasprefix .'_gocal_reservations');
define('GOCAL_Forms_table',$useasprefix .'_gocal_gocal_forms');
define('GOCAL_Forms_Fields_table',$useasprefix .'_gocal_forms_fields');
define('GOCAL_Form_Options_table',$useasprefix.'_gocal_forms_select_options');
该帖子应该是全球wordpress $post
对象;我现在更新了它;
wp_cache_flush();
global $wpdb;
$post = get_queried_object();
$useasprefix=$post->post_author;
// Paths
define('Gocal_Plugin_AbsPath', str_replace('\\', '/', ABSPATH).'wp-content/plugins/go-cal/');
define('Gocal', WP_PLUGIN_URL.'/go-cal/');
// Tables
define('GOCAL_Set_table',$useasprefix .'_gocal_settings');
define('GOCAL_Cal_table',$useasprefix .'_gocal_calendars');
define('GOCAL_Day_table',$useasprefix .'_gocal_dopbs_days');
define('GOCAL_Res_table',$useasprefix .'_gocal_reservations');
define('GOCAL_Forms_table',$useasprefix .'_gocal_gocal_forms');
define('GOCAL_Forms_Fields_table',$useasprefix .'_gocal_forms_fields');
define('GOCAL_Form_Options_table',$useasprefix.'_gocal_forms_select_options');