define_constants(); $this->includes(); $this->init_hooks(); $this->api = new fielddayApi(); $this->engine = new fielddayCore(); $cookieoffset = $this->engine->getCookieStorage('offset', false); if ($cookieoffset) { $fielddaySetting['offset'] = $cookieoffset; } else { $fielddaySetting['offset'] = 300; } /*$cookievisitbefore = $this->engine->getCookieStorage('visitbefore', false); if ($cookievisitbefore) { echo "visitedbefore"; echo $fielddaySetting['visitbefore'] = $cookievisitbefore; } else { echo "notvisitedbefore"; $fielddaySetting['visitbefore'] = ''; }*/ if(isset($_REQUEST['cartId'])){ setcookie('GcartId', $_REQUEST['cartId'], time() + (86400), "/"); // 86400 = 1 day } if(isset($_REQUEST['parentId'])){ setcookie('GparentId',$_REQUEST['parentId'], time() + (86400), "/"); // 86400 = 1 day } $fielddaySetting['siteName'] = get_bloginfo(); if (!$this->engine->getValue('global_popup_key', $fielddaySetting, false)) { $randomnumber = "field_day_" . rand(1, 9999); $fielddaySetting['global_popup_key'] = $randomnumber; } //$fielddaySetting['global_popup_key'] = "_global_discount_check23222"; $this->suffix = (defined('WP_DEBUG') && true === WP_DEBUG) ? "" : '.min'; } /** * Hook into actions and filters. * * @since 1.0.0 */ private function init_hooks() { register_activation_hook(fieldday_PLUGIN_FILE, array($this, 'fieldday_plugin_install')); add_action('init', array($this, 'init'), 0); add_action('after_setup_theme', [$this, 'remove_admin_bar']); /* register front end scripts */ add_action('wp_enqueue_scripts', array($this, 'fielddayScripts'), 0); /* register admin scripts */ add_action('admin_enqueue_scripts', array($this, 'fielddayAdminScripts'), 0); /* add popup messages in footer */ add_action('wp_footer', [$this, 'KmAlertMessages']); add_action('wp_footer', [$this, 'KmStickyWidget']); /* add script in header section */ add_action('wp_head', [$this, 'fielddayHead']); /* add fieldday user into menu selected */ add_filter('wp_nav_menu_items', [$this, 'fielddayUserInMenu'], 999, 2); /* add cart icon into menu selected */ //add_filter('wp_nav_menu_items', [$this, 'fielddayCartInMenu'], 999, 2); } public function fielddayHead() { global $fielddaySetting; $this->engine->getValue('fieldday_header_Script', $fielddaySetting); $kmPrimaryColor = $this->engine->getValue('primary_color', $fielddaySetting, false); $kmSecondaryColor = $this->engine->getValue('secondary_color', $fielddaySetting, false); $kmHighlightColor = $this->engine->getValue('highlightcolor', $fielddaySetting, false); $fieldday_bullets = $this->engine->getValue('fieldday_bullets', $fielddaySetting, false); $fieldday_text_color = $this->engine->getValue('textcolor', $fielddaySetting, false); if($fieldday_text_color==''){$fieldday_text_color="#ffffff";} $fieldday_text_color2 = $this->engine->getValue('textcolor2', $fielddaySetting, false); if($fieldday_text_color2==''){$fieldday_text_color2="#ffffff";} print ""; } /** * user HTML in menu * @global Array $fielddaySetting * @param String $items * @param mixed $args * @return String menu Html */ public function fielddayUserInMenu($items, $args) { global $fielddaySetting; $selectedMenu = $this->engine->getValue('user_menu', $fielddaySetting, false); $selectedCartMenu = $this->engine->getValue('cart_menu', $fielddaySetting, false); if (isset($args->menu->term_id)) { if ($selectedCartMenu == $args->menu->term_id) { $items .= $this->engine->GetCartView(); } if ($selectedMenu == $args->menu->term_id) { $items .= $this->engine->UserInMenuHtml(); } return $items; } else { $menu = wp_get_nav_menu_object($args->menu); if ($selectedCartMenu == $menu->term_id) { $items .= $this->engine->GetCartView(); } if ($selectedMenu == $menu->term_id) { $items .= $this->engine->UserInMenuHtml(); } return $items; } } /* * fieldday instalation hook */ public function fieldday_plugin_install() { } /** * Init plugin when WordPress Initialises. */ public function init() { global $KmUser; $KmUser = $this->getKmUser(); $this->BlockfielddayDashboard(); if (!session_id()) { session_start(); } add_role( fieldday_ROLE, __('fieldday User'), array( 'read' => true, // true allows this capability ) ); } /** * Define fieldday Constants. */ private function define_constants() { $this->define('fieldday_ABSPATH', dirname(fieldday_PLUGIN_FILE) . '/'); $this->define('fieldday_BASENAME', plugin_basename(fieldday_PLUGIN_FILE)); $this->define('fieldday_URL', plugins_url(basename(fieldday_ABSPATH))); $this->define('fieldday_VERSION', $this->version); $this->define('fieldday_PLACEHOLDER', fieldday_URL . '/assets/img/placeholder.png'); $this->define('fieldday_CURRENCY', '$'); $this->define('fieldday_ROLE', 'km_user'); } /** * Include required core files used in admin and on the frontend. */ public function includes() { global $fielddaySetting; $activetheme = array_key_exists('fieldday_theme_mode', $fielddaySetting) ? $fielddaySetting['fieldday_theme_mode'] : null; include_once fieldday_ABSPATH . '/inc/ClassFielddayBase.php'; include_once fieldday_ABSPATH . '/inc/ClassFielddayhubCore.php'; include_once fieldday_ABSPATH . '/lib/FielddayApi/FielddayApi.php'; include_once fieldday_ABSPATH . '/inc/ClassShortcodes.php'; include_once fieldday_ABSPATH . '/inc/ClassActions.php'; include_once fieldday_ABSPATH . '/inc/widgets/classWidgets.php'; /*active theme fucntion file*/ if($activetheme && file_exists(fieldday_ABSPATH . "/views/theme/{$activetheme}/functions.php")) { include_once fieldday_ABSPATH . "/views/theme/{$activetheme}/functions.php"; } /* add admin files */ /* add admin files */ if (is_admin()) { include_once fieldday_ABSPATH . '/inc/ClassAdminOptions.php'; } } /** * get fieldday Current loggedin user * * @return boolean */ public function getKmUser() { $km_user = wp_get_current_user(); if ($km_user) { $meta = get_user_meta($km_user->ID, 'km_user_data', true); if ($meta) { $KmUser = $this->api->getUser($meta->_id, $meta->accessToken); if ($KmUser->statusCode === 200) { $KmUser->data->accessToken = $meta->accessToken; return $KmUser->data; } } } return false; } /* * add some alert messages in wordpress footer */ public function KmAlertMessages() { global $fielddaySetting; $cookieCheck = $this->engine->getCookieStorage($fielddaySetting['global_popup_key'], false); $isenabled = $this->engine->getValue('fieldday_global_popup', $fielddaySetting, false); $isPopupEnablePage = $this->engine->getValue('fieldday_globalpopup_page', $fielddaySetting, false); $pageID = get_the_ID(); if ($isenabled == 'enabled' && !$cookieCheck) { if ($isPopupEnablePage == $pageID || $isPopupEnablePage == 'all') { echo $this->engine->getView('global_popup'); } } global $fielddaySetting; $this->engine->getValue('fieldday_footer_Script', $fielddaySetting); echo $this->engine->getView('fieldday_alerts'); } /* * add some alert messages in wordpress footer */ public function KmStickyWidget(){ global $fielddaySetting; $isenabled = $this->engine->getValue('fieldday_sticky_widget', $fielddaySetting, false); $StickyOption = $this->engine->getValue('fieldday_sticky_option', $fielddaySetting, false); if ($isenabled == 'enable') { echo '
Contact Us Now