本文整理汇总了PHP中FLBuilderModel::get_post_id方法的典型用法代码示例。如果您正苦于以下问题:PHP FLBuilderModel::get_post_id方法的具体用法?PHP FLBuilderModel::get_post_id怎么用?PHP FLBuilderModel::get_post_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FLBuilderModel
的用法示例。
在下文中一共展示了FLBuilderModel::get_post_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bodyClass
public function bodyClass($classes)
{
if (!is_archive()) {
$current_post = get_post(FLBuilderModel::get_post_id());
if ($current_post) {
$post_has_ct = get_post_meta($current_post->ID, '_views_template', true);
if ($post_has_ct) {
$ct_has_beaver = get_post_meta($post_has_ct, '_fl_builder_enabled', true);
if ($ct_has_beaver) {
$classes[] = 'fl-builder';
}
}
}
}
return $classes;
}
示例2: render_css
/**
* Renders and caches the CSS for a builder layout.
*
* @since 1.0
* @return void
*/
public static function render_css()
{
// Delete the old file.
FLBuilderModel::delete_asset_cache('css');
// Get info on the new file.
$nodes = FLBuilderModel::get_categorized_nodes();
$global_settings = FLBuilderModel::get_global_settings();
$asset_info = FLBuilderModel::get_asset_info();
$post_id = FLBuilderModel::get_post_id();
$post = get_post($post_id);
$compiled = array();
// Global css
$css = file_get_contents(FL_BUILDER_DIR . '/css/fl-builder-layout.css');
// Global RTL css
if (is_rtl()) {
$css .= file_get_contents(FL_BUILDER_DIR . '/css/fl-builder-layout-rtl.css');
}
// Responsive css
if ($global_settings->responsive_enabled) {
$css .= '@media (max-width: ' . $global_settings->medium_breakpoint . 'px) { ';
$css .= file_get_contents(FL_BUILDER_DIR . '/css/fl-builder-layout-medium.css');
$css .= ' }';
$css .= '@media (max-width: ' . $global_settings->responsive_breakpoint . 'px) { ';
$css .= file_get_contents(FL_BUILDER_DIR . '/css/fl-builder-layout-responsive.css');
if (!isset($global_settings->auto_spacing) || $global_settings->auto_spacing) {
$css .= file_get_contents(FL_BUILDER_DIR . '/css/fl-builder-layout-auto-spacing.css');
}
$css .= ' }';
}
// Global row margins
$css .= '.fl-row-content-wrap { margin: ' . $global_settings->row_margins . 'px; }';
// Global row padding
$css .= '.fl-row-content-wrap { padding: ' . $global_settings->row_padding . 'px; }';
// Global row width
$css .= '.fl-row-fixed-width { max-width: ' . $global_settings->row_width . 'px; }';
// Global module margins
$css .= '.fl-module-content { margin: ' . $global_settings->module_margins . 'px; }';
// Loop through rows
foreach ($nodes['rows'] as $row) {
// Instance row css
ob_start();
include FL_BUILDER_DIR . 'includes/row-css.php';
$css .= ob_get_clean();
// Instance row margins
$css .= self::render_row_margins($row);
// Instance row padding
$css .= self::render_row_padding($row);
}
// Loop through the columns.
foreach ($nodes['columns'] as $col) {
// Instance column css
ob_start();
include FL_BUILDER_DIR . 'includes/column-css.php';
$css .= ob_get_clean();
// Instance column margins
$css .= self::render_column_margins($col);
// Instance column padding
$css .= self::render_column_padding($col);
// Get the modules in this column.
$modules = FLBuilderModel::get_modules($col);
}
// Loop through the modules.
foreach ($nodes['modules'] as $module) {
// Global module css
$file = $module->dir . 'css/frontend.css';
$file_responsive = $module->dir . 'css/frontend.responsive.css';
// Only include global module css that hasn't been included yet.
if (!in_array($module->settings->type, $compiled)) {
// Add to the compiled array so we don't include it again.
$compiled[] = $module->settings->type;
// Get the standard module css.
if (file_exists($file)) {
$css .= file_get_contents($file);
}
// Get the responsive module css.
if ($global_settings->responsive_enabled && file_exists($file_responsive)) {
$css .= '@media (max-width: ' . $global_settings->responsive_breakpoint . 'px) { ';
$css .= file_get_contents($file_responsive);
$css .= ' }';
}
}
// Instance module css
$file = $module->dir . 'includes/frontend.css.php';
$settings = $module->settings;
$id = $module->node;
if (file_exists($file)) {
ob_start();
include $file;
$css .= ob_get_clean();
}
// Instance module margins
$css .= self::render_module_margins($module);
if (!isset($global_settings->auto_spacing) || $global_settings->auto_spacing) {
$css .= self::render_responsive_module_margins($module);
//.........这里部分代码省略.........
示例3: call_action
/**
* Runs the current AJAX action.
*
* @since 1.7
* @access private
* @return void
*/
private static function call_action()
{
// Only run for logged in users.
if (!is_user_logged_in()) {
return;
}
// Get the $_POST data.
$post_data = FLBuilderModel::get_post_data();
// Get the post ID.
$post_id = FLBuilderModel::get_post_id();
// Make sure the user can edit this post.
if ($post_id && !current_user_can('edit_post', $post_id)) {
return;
}
// Get the action.
if (!empty($_REQUEST['fl_action'])) {
$action = $_REQUEST['fl_action'];
} else {
if (!empty($post_data['fl_action'])) {
$action = $post_data['fl_action'];
} else {
return;
}
}
// Make sure the action exists.
if (!isset(self::$actions[$action])) {
return;
}
// Get the action data.
$action = self::$actions[$action];
$args = array();
// Build the args array.
foreach ($action['args'] as $arg) {
$args[] = isset($post_data[$arg]) ? $post_data[$arg] : null;
}
// Tell WordPress this is an AJAX request.
define('DOING_AJAX', true);
// Call the method.
$result = call_user_func_array($action['method'], $args);
// JSON encode the result.
echo json_encode($result);
// Complete the request.
die;
}
示例4: call_action
/**
* Runs the current AJAX action.
*
* @since 1.7
* @access private
* @return void
*/
private static function call_action()
{
// Only run for logged in users.
if (!is_user_logged_in()) {
return;
}
// Verify the AJAX nonce.
if (!self::verify_nonce()) {
return;
}
// Get the $_POST data.
$post_data = FLBuilderModel::get_post_data();
// Get the post ID.
$post_id = FLBuilderModel::get_post_id();
// Make sure we have a post ID.
if (!$post_id) {
return;
}
// Make sure the user can edit this post.
if (!current_user_can('edit_post', $post_id)) {
return;
}
// Get the action.
if (!empty($_REQUEST['fl_action'])) {
$action = $_REQUEST['fl_action'];
} else {
if (!empty($post_data['fl_action'])) {
$action = $post_data['fl_action'];
} else {
return;
}
}
// Make sure the action exists.
if (!isset(self::$actions[$action])) {
return;
}
// Get the action data.
$action = self::$actions[$action];
$args = array();
$keys_args = array();
// Build the args array.
foreach ($action['args'] as $arg) {
$args[] = $keys_args[$arg] = isset($post_data[$arg]) ? $post_data[$arg] : null;
}
// Tell WordPress this is an AJAX request.
define('DOING_AJAX', true);
// Allow developers to hook before the action runs.
do_action('fl_ajax_before_' . $action['action'], $keys_args);
// Call the action and allow developers to filter the result.
$result = apply_filters('fl_ajax_' . $action['action'], call_user_func_array($action['method'], $args), $keys_args);
// Allow developers to hook after the action runs.
do_action('fl_ajax_after_' . $action['action'], $keys_args);
// JSON encode the result.
echo json_encode($result);
// Complete the request.
die;
}