本文整理汇总了PHP中FLBuilderModel::get_all_modules方法的典型用法代码示例。如果您正苦于以下问题:PHP FLBuilderModel::get_all_modules方法的具体用法?PHP FLBuilderModel::get_all_modules怎么用?PHP FLBuilderModel::get_all_modules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FLBuilderModel
的用法示例。
在下文中一共展示了FLBuilderModel::get_all_modules方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_fl_builder_data
public static function save_fl_builder_data($meta_id, $post_id, $meta_key, $meta_value)
{
if ('_fl_builder_data' === $meta_key) {
$modules = FLBuilderModel::get_all_modules();
$nodes = self::find_fields($modules);
if (!empty($nodes)) {
$draft = maybe_unserialize(get_post_meta($post_id, '_fl_builder_draft', true));
$meta_value = maybe_unserialize($meta_value);
foreach ($nodes as $node_id => $types) {
foreach ($types as $type => $fields) {
foreach ($fields as $field => $args) {
if ('fl-builder-template' !== get_post_type($post_id)) {
if ($type == 'meta') {
update_post_meta($post_id, $args['key'], $args['val']);
}
if ($type == 'taxonomy') {
wp_set_post_terms($post_id, $args['val'], $args['key']);
}
if ($type == 'wp_option') {
update_option($args['key'], $args['val']);
}
}
if (isset($meta_value[$node_id]->settings->{$field})) {
unset($meta_value[$node_id]->settings->{$field});
}
if (isset($draft[$node_id]->settings->{$field})) {
unset($draft[$node_id]->settings->{$field});
}
}
}
}
update_post_meta($post_id, $meta_key, $meta_value);
update_post_meta($post_id, '_fl_builder_draft', $draft);
}
}
}
示例2: render_js
/**
* Renders and caches the JavaScript for a builder layout.
*
* @since 1.0
* @return void
*/
public static function render_js()
{
// Delete the old file.
FLBuilderModel::delete_asset_cache('js');
// Get info on the new file.
$global_settings = FLBuilderModel::get_global_settings();
$rows = FLBuilderModel::get_nodes('row');
$modules = FLBuilderModel::get_all_modules();
$asset_info = FLBuilderModel::get_asset_info();
$compiled = array();
$js = '';
// Main JS
$js .= file_get_contents(FL_BUILDER_DIR . 'js/fl-builder-layout.js');
// Instance Row JS
foreach ($rows as $row) {
$settings = $row->settings;
$id = $row->node;
ob_start();
include FL_BUILDER_DIR . 'includes/row-js.php';
$js .= ob_get_clean();
}
// Modules
foreach ($modules as $module) {
// Global module JS
$file = $module->dir . 'js/frontend.js';
if (file_exists($file) && !in_array($module->settings->type, $compiled)) {
$js .= "\n" . file_get_contents($file);
$compiled[] = $module->settings->type;
}
// Instance module JS
$file = $module->dir . 'includes/frontend.js.php';
$settings = $module->settings;
$id = $module->node;
if (file_exists($file)) {
ob_start();
include $file;
$js .= ob_get_clean();
}
}
// Add the AJAX url global.
$js .= "var wpAjaxUrl = '" . admin_url('admin-ajax.php') . "';";
// Add the builder url global.
$js .= "var flBuilderUrl = '" . FL_BUILDER_URL . "';";
// Call the FLBuilder._renderLayoutComplete method if we're currently editing.
if (stristr($asset_info['js'], '-draft.js') || stristr($asset_info['js'], '-preview.js')) {
$js .= "; if(typeof FLBuilder !== 'undefined' && typeof FLBuilder._renderLayoutComplete !== 'undefined') FLBuilder._renderLayoutComplete();";
}
// Include FLJSMin
if (!class_exists('FLJSMin')) {
include FL_BUILDER_DIR . 'classes/class-fl-jsmin.php';
}
// Save the js
if (!empty($js)) {
file_put_contents($asset_info['js'], FLJSMin::minify($js));
}
}