diff --git a/phpcs.xml b/phpcs.xml index 341399c..68267ec 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -4,5 +4,7 @@ tests/ - + + + diff --git a/src/class-install-command.php b/src/class-install-command.php index a2598c1..4b5f80e 100644 --- a/src/class-install-command.php +++ b/src/class-install-command.php @@ -54,6 +54,12 @@ protected function execute( InputInterface $input, OutputInterface $output ): in |_| |_|\__,_|_| |_|\__|_|\___| \n\n" ); + if ( $this->check_if_hiring() ) { + $output->write( + "Alley is hiring! Apply today at https://alley.co/careers/. \n\n" + ); + } + // Determine if we're in a WordPress project already. $wordpress_root = $this->get_wordpress_root( $input, $output ); @@ -127,7 +133,7 @@ protected function get_wordpress_root( InputInterface $input, OutputInterface $o null, /** * Callback function that handles validating the manually defined WordPress installation directory. - * + * * @param string $dir The full path to the WordPress directory, as defined by the user. * @return string $dir The path as passed by the user, after passing validation. */ @@ -340,4 +346,39 @@ protected function get_mu_plugin_loader( string $plugin_name ): string { } EOT; } + + /** + * Check if Alley is hiring and throw a prompt. + * + * @return boolean + */ + protected function check_if_hiring(): bool { + try { + $ch = curl_init(); + curl_setopt( $ch, CURLOPT_URL, 'https://careers.alley.co/wp-json/wp/v2/job/' ); + curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); + curl_setopt( $ch, CURLOPT_TIMEOUT, 3 ); + + $feed = json_decode( curl_exec( $ch ), true ); + + curl_close( $ch ); + } catch ( \Throwable $e ) { + return false; + } + + if ( empty( $feed ) ) { + return false; + } + + // Check if there is a developer posting in the feed. + foreach ( $feed as $posting ) { + $title = strtolower( $posting['title']['rendered'] ?? '' ); + + if ( false !== strpos( $title, 'developer' ) ) { + return true; + } + } + + return false; + } }