5TNr`TVSNr`TVSNr`TV`]S?wordfencels\auth_redirectt&F~Owordfencels\is_user_logged_in1dɌwordfencels\controller_settingsc c wordfencels\shortcode_atts6TNr`TVg"wordfencels\wp_enqueue_style8TNr`TV|8wordfencels\has_shortcode1dɌwordfencels\controller_settingsH9TNr`TVPnHwordfencels\wp_get_current_userPnHwordfencels\wp_get_current_user'?wordfencels\utility_arrayqr%ATwordfencels\controller_usersPnHwordfencels\wp_get_current_user1dɌwordfencels\controller_settings:TNr`TV?L fwordfencels\wc_add_notice;TNr`TVSNr`TV()0YWordfenceLS\remove_action=TNr`TVSyK3WordfenceLS\apply_filtersH>TNr`TV@SNr`TV/}>+L8wordfencels\controller_time0slZwordfencels\crypto\model_jwtiքzkRWordfenceLS\get_site_option>WZuwordfencels\model_requestDr%ATwordfencels\controller_users SNr`TV?TNr`TV `}kwordfencels\controller_captcha@TNr`TV>WZuwordfencels\model_requestSNr`TVBTNr`TVc;Vwordfencels\text\model_htmlHCTNr`TV"WordfenceLS\Controller_Support"WordfenceLS\Controller_SupportDTNr`TV{Twordfencels\view\model_tabETNr`TVSNr`TVe^kwordfencels\controller_supportGTNr`TVe^kwordfencels\controller_support&!wordfencels\view\model_title&!wordfencels\view\model_titler%ATwordfencels\controller_usersHHTNr`TV1dɌwordfencels\controller_settingsPnHwordfencels\wp_get_current_userITNr`TVPnHwordfencels\wp_get_current_userJTNr`TVvE>wordfencels\add_menu_page@f>nwordfencels\add_submenu_page'x>i>(wordfencels\is_super_adminLTNr`TVJlUwordfencels\is_network_adminxC˾+Zwordfencels\is_multisitetHMTNr`TV4?wordfencels\current_user_can9πkwordfencels\controller_notices9πkwordfencels\controller_noticesr%ATwordfencels\controller_users9πkwordfencels\controller_noticesPnHwordfencels\wp_get_current_userA } $reference = new Puc_v4p11_Vcs_Reference(array( 'name' => $branch->name, 'downloadUrl' => $this->buildArchiveDownloadUrl($branch->name), 'apiResponse' => $branch, )); if ( isset($branch->commit, $branch->commit->committed_date) ) { $reference->updated = $branch->commit->committed_date; } return $reference; } /** * Get the timestamp of the latest commit that changed the specified branch or tag. * * @param string $ref Reference name (e.g. branch or tag). * @return string|null */ public function getLatestCommitTime($ref) { $commits = $this->api('/:id/repository/commits/', array('ref_name' => $ref)); if ( is_wp_error($commits) || !is_array($commits) || !isset($commits[0]) ) { return null; } return $commits[0]->committed_date; } /** * Perform a GitLab API request. * * @param string $url * @param array $queryParams * @return mixed|WP_Error */ protected function api($url, $queryParams = array()) { $baseUrl = $url; $url = $this->buildApiUrl($url, $queryParams); $options = array('timeout' => 10); if ( !empty($this->httpFilterName) ) { $options = apply_filters($this->httpFilterName, $options); } $response = wp_remote_get($url, $options); if ( is_wp_error($response) ) { do_action('puc_api_error', $response, null, $url, $this->slug); return $response; } $code = wp_remote_retrieve_response_code($response); $body = wp_remote_retrieve_body($response); if ( $code === 200 ) { return json_decode($body); } $error = new WP_Error( 'puc-gitlab-http-error', sprintf('GitLab API error. URL: "%s", HTTP status code: %d.', $baseUrl, $code) ); do_action('puc_api_error', $error, $response, $url, $this->slug); return $error; } /** * Build a fully qualified URL for an API request. * * @param string $url * @param array $queryParams * @return string */ protected function buildApiUrl($url, $queryParams) { $variables = array( 'user' => $this->userName, 'repo' => $this->repositoryName, 'id' => $this->userName . '/' . $this->repositoryName, ); foreach ($variables as $name => $value) { $url = str_replace("/:{$name}", '/' . urlencode($value), $url); } $url = substr($url, 1); $url = sprintf('%1$s://%2$s/api/v4/projects/%3$s', $this->repositoryProtocol, $this->repositoryHost, $url); if ( !empty($this->accessToken) ) { $queryParams['private_token'] = $this->accessToken; } if ( !empty($queryParams) ) { $url = add_query_arg($queryParams, $url); } return $url; } /** * Get the contents of a file from a specific branch or tag. * * @param string $path File name. * @param string $ref * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error. */ public function getRemoteFile($path, $ref = 'master') { $response = $this->api('/:id/repository/files/' . $path, array('ref' => $ref)); if ( is_wp_error($response) || !isset($response->content) || $response->encoding !== 'base64' ) { return null; } return base64_decode($response->content); } /** * Generate a URL to download a ZIP archive of the specified branch/tag/etc. * * @param string $ref * @return string */ public function buildArchiveDownloadUrl($ref = 'master') { $url = sprintf( '%1$s://%2$s/api/v4/projects/%3$s/repository/archive.zip', $this->repositoryProtocol, $this->repositoryHost, urlencode($this->userName . '/' . $this->repositoryName) ); $url = add_query_arg('sha', urlencode($ref), $url); if ( !empty($this->accessToken) ) { $url = add_query_arg('private_token', $this->accessToken, $url); } return $url; } /** * Get a specific tag. * * @param string $tagName * @return void */ public function getTag($tagName) { throw new LogicException('The ' . __METHOD__ . ' method is not implemented and should not be used.'); } /** * Figure out which reference (i.e tag or branch) contains the latest version. * * @param string $configBranch Start looking in this branch. * @return null|Puc_v4p11_Vcs_Reference */ public function chooseReference($configBranch) { $updateSource = null; // GitLab doesn't handle releases the same as GitHub so just use the latest tag if ( $configBranch === 'master' ) { $updateSource = $this->getLatestTag(); } if ( empty($updateSource) ) { $updateSource = $this->getBranch($configBranch); } return $updateSource; } public function setAuthentication($credentials) { parent::setAuthentication($credentials); $this->accessToken = is_string($credentials) ? $credentials : null; } } endif;