/** * Fetch single module data * @since 0.1.0 */ function ls_get_module_data($module_name) { if (isset($module_name)) { $modules = ls_get_modules(); return $modules[$module_name]; } return false; }
/** * Remove custom plugin pages from wordpress * @since 0.1.0 */ function remove_custom_pages() { $modules = ls_get_modules(); // Run over all modules and start them up foreach ($modules as $module) { $page_id = $module['custom_page_id']; // If custom page has been created delete page permanantely and skip the trash if ($page_id) { wp_delete_post($page_id, true); } } }
/** * Settings * Initiates modules based on their active definition in the $ls_settings * @since 0.1.0 */ function init_modules() { $ls_helpers = $this->ls_helpers; $modules = ls_get_modules(); $dir = $ls_helpers->get_path(); // Run over all modules and start them up foreach ($modules as $module_name => $module) { if ($module['active']) { $base_dir = str_replace('/core', '', $dir); $base_dir = str_replace('\\core', '', $base_dir); $base_dir = str_replace('/', LS_SLASH, $base_dir); require_once $base_dir . $module['path']; } } }
/** * Render sidebar html where needed * @since 0.1.0 */ function ls_render_sidebar_html() { $ls_helpers = new ls_helpers(); $modules = ls_get_modules(); ?> <div class="ls-module-wrapper"> <ul class="ls-modules-slim"> <?php foreach ($modules as $module_key => $module) { ?> <li class="ls-modules-slim__rack <?php echo $module['active'] ? 'ls-modules-slim__rack--active js-ls-modules-slim__rack--active' : 'js-ls-modules-slim__rack--disabled'; ?> "> <div class="ls-modules-slim__module-button"> <span class="ls-modules-slim__module-icon <?php echo $module['icon']; ?> "></span> <span class="ls-modules-slim__module-title"><?php echo $module['title']; ?> </span> </div> <?php if ($module['active']) { $data_attribute = 'data-href="' . $ls_helpers->get_plugin_page_url($module['slug']) . '"'; } else { $data_attribute = 'data-module-name="' . $module_key . '"'; } ?> <div class="ls-modules-slim__module js-ls-modules-slim__module" <?php echo $data_attribute; ?> > <div class="ls-modules-slim__activate"> <div class="ls-module-slim__activate__text"> <?php if (!$module['active']) { echo $module['module_tray_text']['disabled']; } else { echo $module['module_tray_text']['active']; } ?> </div> </div> </div> </li><?php } ?> <li class="ls-modules-slim__rack ls-modules-slim__rack--extras"> <a href="<?php echo $ls_helpers->get_plugin_page_url('live-site-backoffice'); ?> " class="ls-modules-slim__module-button"> <span class="ls-modules-slim__module-icon icon-Optimization"></span> <span class="ls-modules-slim__module-title"><?php _e('Back Office', 'livesite'); ?> </span> </a> </li> <li class="ls-modules-slim__rack ls-modules-slim__rack--extras"> <a href="//developers.vcita.com" target="_blank" class="ls-modules-slim__module-button"> <span class="ls-modules-slim__module-icon icon-Code-Window"></span> <span class="ls-modules-slim__module-title"><?php _e('SDK', 'livesite'); ?> </span> </a> </li> </ul> </div> <?php }
/** * Settings * Replaces double curly braces with vcita data in modules * @param: $vcita_data{Array} * @since 0.1.0 */ function ls_replace_default_tags() { $modules = ls_get_modules(); $settings = ls_get_settings(); // $ls_helpers->console_log( $settings ); // Run over all modules foreach ($modules as $module_name => $module) { if (isset($module['custom_page_content'])) { // Replace data inside of custom page content $custom_page_content_parsed = $this->tag_replace($module['custom_page_content'], $settings['vcita_params']); // TODO: Fix this. For some reason ls_set_settings overrides the vcita_params and does not merge the arrays correctly // Set module as active based on array key name ls_set_module_data($module_name, array('custom_page_content' => $custom_page_content_parsed)); // $ls_helpers->console_log( $ ); } } // $ls_helpers->console_log( $modules ); }