本文整理汇总了PHP中FLBuilderModel::get_module方法的典型用法代码示例。如果您正苦于以下问题:PHP FLBuilderModel::get_module方法的具体用法?PHP FLBuilderModel::get_module怎么用?PHP FLBuilderModel::get_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FLBuilderModel
的用法示例。
在下文中一共展示了FLBuilderModel::get_module方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit
/**
* Called via AJAX to submit the subscribe form.
*
* @since 1.5.2
* @return string The JSON encoded response.
*/
public function submit()
{
$name = isset($_POST['name']) ? sanitize_text_field($_POST['name']) : false;
$email = isset($_POST['email']) ? sanitize_email($_POST['email']) : false;
$node_id = isset($_POST['node_id']) ? sanitize_text_field($_POST['node_id']) : false;
$result = array('action' => false, 'error' => false, 'message' => false, 'url' => false);
if ($email && $node_id) {
$module = FLBuilderModel::get_module($node_id);
$settings = $module->settings;
// Subscribe.
$instance = FLBuilderServices::get_service_instance($settings->service);
$response = $instance->subscribe($settings, $email, $name);
// Check for an error from the service.
if ($response['error']) {
$result['error'] = $response['error'];
} else {
$result['action'] = $settings->success_action;
if ('message' == $settings->success_action) {
$result['message'] = $settings->success_message;
} else {
$result['url'] = $settings->success_url;
}
}
} else {
$result['error'] = __('There was an error subscribing. Please try again.', 'fl-builder');
}
echo json_encode($result);
die;
}
示例2: get_partial_refresh_data
/**
* Returns an array of partial refresh data.
*
* @since 1.7
* @access private
* @return array
*/
private static function get_partial_refresh_data()
{
// Get the data if it's not cached.
if (!self::$partial_refresh_data) {
$post_data = FLBuilderModel::get_post_data();
$partial_refresh = false;
// Check for partial refresh if we have a node ID.
if (isset($post_data['node_id'])) {
// Get the node.
$node_id = $post_data['node_id'];
$node = FLBuilderModel::get_node($post_data['node_id']);
// Check a module for partial refresh.
if ($node && 'module' == $node->type) {
$node = FLBuilderModel::get_module($node_id);
$node_type = 'module';
$partial_refresh = $node->partial_refresh;
} else {
if ($node) {
$node_type = $node->type;
$partial_refresh = self::node_modules_support_partial_refresh($node);
}
}
}
// Clear the node data if we're not doing a partial refresh.
if (!$partial_refresh) {
$node_id = null;
$node = null;
$node_type = null;
}
// Cache the partial refresh data.
self::$partial_refresh_data = array('is_partial_refresh' => $partial_refresh, 'node_id' => $node_id, 'node' => $node, 'node_type' => $node_type);
}
// Return the data.
return self::$partial_refresh_data;
}
示例3: render_fields
/**
* Render the markup for service specific fields.
*
* Called via the fl_ajax_fl_builder_render_service_fields action.
*
* @since 1.5.4
* @return string The JSON encoded response.
*/
public static function render_fields()
{
$post_data = FLBuilderModel::get_post_data();
$module = FLBuilderModel::get_module($post_data['node_id']);
$instance = self::get_service_instance($post_data['service']);
$response = $instance->render_fields($post_data['account'], $module->settings);
echo json_encode($response);
die;
}
示例4: render_module_settings
/**
* Renders the settings lightbox for a module.
*
* @since 1.0
* @param string $node_id The module node ID.
* @param string $type The type of module.
* @param string $parent_id The parent column node ID.
* @param bool $return Whether to return the layout data or echo it.
* @return void
*/
public static function render_module_settings($node_id = null, $type = null, $parent_id = null, $return = false)
{
$post_data = FLBuilderModel::get_post_data();
$node_id = isset($post_data['node_id']) ? $post_data['node_id'] : $node_id;
$type = isset($post_data['type']) ? $post_data['type'] : $type;
$parent_id = isset($post_data['parent_id']) ? $post_data['parent_id'] : $parent_id;
$buttons = array();
// Get the module and settings.
if ($node_id) {
$module = FLBuilderModel::get_module($node_id);
$settings = $module->settings;
} else {
$module = FLBuilderModel::$modules[$type];
$settings = FLBuilderModel::get_module_defaults($type);
}
// Is this module global?
$global = FLBuilderModel::is_node_global($module);
// Add the Save As button?
if (!$global && !FLBuilderModel::is_post_node_template() && FLBuilderModel::node_templates_enabled()) {
$buttons[] = 'save-as';
}
// Render the settings CSS/JS.
if (file_exists($module->dir . 'css/settings.css')) {
echo '<link class="fl-builder-settings-css" rel="stylesheet" href="' . $module->url . 'css/settings.css" />';
}
if (file_exists($module->dir . 'js/settings.js')) {
echo '<script class="fl-builder-settings-js" src="' . $module->url . 'js/settings.js"></script>';
}
// Render the form.
echo self::render_settings(array('class' => 'fl-builder-module-settings fl-builder-' . $type . '-settings', 'attrs' => 'data-node="' . $node_id . '" data-parent="' . $parent_id . '" data-type="' . $type . '"', 'title' => sprintf(_x('%s Settings', '%s stands for module name.', 'fl-builder'), $module->name), 'badges' => $global ? array('global' => _x('Global', 'Indicator for global node templates.', 'fl-builder')) : array(), 'tabs' => $module->form, 'buttons' => $buttons), $settings, $return);
}
示例5: render_module_js
/**
* Renders the JavaScript for a single module.
*
* @since 1.7
* @param string|object $module_id A module ID or object.
* @param array $compiled An array of module types that have already has frontend.js compiled.
* @return string
*/
public static function render_module_js($module_id, &$compiled = array())
{
$module = is_object($module_id) ? $module_id : FLBuilderModel::get_module($module_id);
$global_settings = FLBuilderModel::get_global_settings();
$js = '';
// 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();
}
// Return the JS.
return $js;
}
示例6: render_module_settings
/**
* Renders the settings lightbox for a module.
*
* @since 1.0
* @param string $node_id The module node ID.
* @param string $type The type of module.
* @param string $parent_id The parent column node ID.
* @param bool $return Whether to return the layout data or echo it.
* @return void
*/
public static function render_module_settings($node_id = null, $type = null, $parent_id = null, $return = false)
{
$post_data = FLBuilderModel::get_post_data();
$node_id = isset($post_data['node_id']) ? $post_data['node_id'] : $node_id;
$type = isset($post_data['type']) ? $post_data['type'] : $type;
$parent_id = isset($post_data['parent_id']) ? $post_data['parent_id'] : $parent_id;
if ($node_id) {
$module = FLBuilderModel::get_module($node_id);
$settings = $module->settings;
} else {
$module = FLBuilderModel::$modules[$type];
$settings = FLBuilderModel::get_module_defaults($type);
}
if (file_exists($module->dir . 'css/settings.css')) {
echo '<link class="fl-builder-settings-css" rel="stylesheet" href="' . $module->url . 'css/settings.css" />';
}
if (file_exists($module->dir . 'js/settings.js')) {
echo '<script class="fl-builder-settings-js" src="' . $module->url . 'js/settings.js"></script>';
}
echo self::render_settings(array('class' => 'fl-builder-module-settings fl-builder-' . $type . '-settings', 'attrs' => 'data-node="' . $node_id . '" data-parent="' . $parent_id . '" data-type="' . $type . '"', 'title' => sprintf(_x('%s Settings', '%s stands for module name.', 'fl-builder'), $module->name), 'tabs' => $module->form), $settings, $return);
}