function bapi_sync_coredata() { $syncdebugmode = 0; $do_core_update = false; //Check if developer is using debugmode and force entity sync if (isset($_GET['syncdebugmode']) && $_GET['syncdebugmode']) { $do_core_update = true; $syncdebugmode = 1; echo '<!--synctest-->'; } if (!(strpos($_SERVER['REQUEST_URI'], 'wp-admin') === false) || !(strpos($_SERVER['REQUEST_URI'], 'wp-login') === false)) { return false; } // initialize the bapisync object global $bapisync; $bapisync = new BAPISync(); $bapisync->init(); $bapi = getBAPIObj(); if (!$bapi->isvalid()) { return; } // check if we need to refresh solution data $data = BAPISync::getSolutionDataRaw(); $lastmod = BAPISync::getSolutionDataLastModRaw(); if (empty($data) || empty($lastmod) || time() - $lastmod > 3600 || $do_core_update || BAPISync::obsoletedByLastSettingsUpdate($lastmod)) { $data = $bapi->getcontext(true, $syncdebugmode); if (!empty($data)) { $tagline = $data['SolutionTagline']; $solName = $data['SolutionNameInformal']; $data = json_encode($data); // convert back to text update_option('bapi_solutiondata', $data); update_option('bapi_solutiondata_lastmod', time()); update_option('blogdescription', $tagline); update_option('blogname', $solName); } } // check if we need to refresh seo data $data = BAPISync::getSEODataRaw(); $lastmod = BAPISync::getSEODataLastModRaw(); if (empty($data) || empty($lastmod) || time() - $lastmod > 300 || $do_core_update || BAPISync::obsoletedByLastSettingsUpdate($lastmod)) { $data = $bapi->getseodata(true, $syncdebugmode); if (!empty($data)) { $data = $data['result']; // just get the result part $data = json_encode($data); // convert back to text update_option('bapi_keywords_array', $data); update_option('bapi_keywords_lastmod', time()); } } }