/** * Back-end widget form. * Outputs the options form on admin * * @see WP_Widget::form() * * @param array $instance * Previously saved values from database. * @since 1.0 * @author Panagiotis Vagenas <*****@*****.**> */ public function form($instance) { // Fill missing options if (empty($instance)) { $instance = erpPRODefaults::$comOpts + erpPRODefaults::$widOpts; } else { $instance = $instance + erpPRODefaults::$comOpts + erpPRODefaults::$widOpts; } // Pass it to viewData erpPROPaths::requireOnce(erpPROPaths::$erpPROView); $widgetInstance = $this; $optionsTemplate = EPR_PRO_BASE_PATH . 'admin/views/widgetSettings.php'; erpPROView::render($optionsTemplate, array('options' => $instance, 'widgetInstance' => $widgetInstance), true); }
/** * Echoes html to be desplayed in shortcode helper * * @author Panagiotis Vagenas <*****@*****.**> * @since 1.0.0 */ public function getShortCodeHelperContent() { if (!current_user_can('edit_posts')) { echo json_encode(array('error' => 'Action not allowed')); die; } erpPROPaths::requireOnce(erpPROPaths::$erpPROShortCodeOpts); $profilesOptionsArray = get_option(erpPROShortCodeOpts::$shortCodeProfilesArrayName); // If profile name is set get options if (isset($_GET['profileName'])) { $profileName = wp_strip_all_tags($_GET['profileName']); $profileOpts = isset($profilesOptionsArray[$profileName]) ? $profilesOptionsArray[$profileName] : null; } // If no options are set get first profile in the array if (empty($profileOpts)) { $profileName = array_shift(array_keys($profilesOptionsArray)); $profileOpts = $profileName === null ? null : $profilesOptionsArray[$profileName]; } // Profile array is empty or profile not found, set to defaults if (empty($profileOpts)) { $profileOpts = erpPRODefaults::$comOpts + erpPRODefaults::$shortCodeOpts; $profileName = 'default'; } erpPROPaths::requireOnce(erpPROPaths::$VPluginThemeFactory); VPluginThemeFactory::registerThemeInPathRecursive(erpPROPaths::getAbsPath(erpPROPaths::$scThemesFolder), $profileOpts['dsplLayout']); $template = VPluginThemeFactory::getThemeByName($profileOpts['dsplLayout']); if (!$template) { echo json_encode(array('error' => 'Theme is not defined')); die; } erpPROPaths::requireOnce(erpPROPaths::$erpPROView); echo erpPROView::render(plugin_dir_path(__FILE__) . '/views/shortcodeHelper.php', array('profileName' => $profileName, 'erpPROOptions' => $profileOpts, 'shortCodeProfilesArrayName' => $this->shortCodeProfilesArrayName)); die; }