From 7488930efef50363171144a480ed323cc6585cc1 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Thu, 19 Oct 2023 13:05:20 +0300 Subject: [PATCH 1/6] Set up footer plugin --- .gitignore | 9 +- .../plugins/academy-africa/academy-africa.php | 44 +++ .../includes/assets/css/academy-africa.css | 0 .../includes/assets/css/footer.css | 260 +++++++++++++++++ .../includes/assets/css/header.css | 0 .../academy-africa/includes/plugin.php | 261 ++++++++++++++++++ .../includes/widgets/footer.php | 118 ++++++++ 7 files changed, 689 insertions(+), 3 deletions(-) create mode 100644 wp-content/plugins/academy-africa/academy-africa.php create mode 100644 wp-content/plugins/academy-africa/includes/assets/css/academy-africa.css create mode 100644 wp-content/plugins/academy-africa/includes/assets/css/footer.css create mode 100644 wp-content/plugins/academy-africa/includes/assets/css/header.css create mode 100644 wp-content/plugins/academy-africa/includes/plugin.php create mode 100644 wp-content/plugins/academy-africa/includes/widgets/footer.php diff --git a/.gitignore b/.gitignore index 3f9c8036..56e77fea 100644 --- a/.gitignore +++ b/.gitignore @@ -62,10 +62,7 @@ wp-content/mu-plugins/wpe-wp-sign-on-plugin* /wp-admin /wp-includes /wp-content/themes/* -!/wp-content/themes/academyAfrica -!/wp-content/themes/hello-elementor /wp-content/plugins/* -!/wp-content/plugins/index.php /wp-content/mu-plugins .htaccess apple-touch-icon-precomposed.png @@ -74,6 +71,7 @@ favicon.ico wpe-deploy-status-academyafrica robots.txt wordpress +node_modules # large/disallowed file types # a CDN should be used for these @@ -111,3 +109,8 @@ wordpress *.avi .env + +!/wp-content/themes/academyAfrica +!/wp-content/themes/hello-elementor +!/wp-content/plugins/index.php +!/wp-content/plugins/academy-africa \ No newline at end of file diff --git a/wp-content/plugins/academy-africa/academy-africa.php b/wp-content/plugins/academy-africa/academy-africa.php new file mode 100644 index 00000000..2161d594 --- /dev/null +++ b/wp-content/plugins/academy-africa/academy-africa.php @@ -0,0 +1,44 @@ +is_compatible()) { + add_action('elementor/init', [$this, 'init']); + } + } + + /** + * Compatibility Check + * + * Checks if the installed version of Elementor meets the plugin's minimum requirement. + * + * @since 1.0.0 + * @access public + */ + + public function is_compatible() + { + // Check if Elementor installed and activated + if (!did_action('elementor/loaded')) { + add_action('admin_notices', [$this, 'admin_notice_missing_main_plugin']); + return false; + } + + // Check if the installed version of Elementor meets the plugin's minimum requirement. + if (!version_compare(ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=')) { + add_action('admin_notices', [$this, 'admin_notice_minimum_elementor_version']); + return false; + } + + // Check if the installed version of PHP meets the plugin's minimum requirement. + if (!version_compare(PHP_VERSION, self::MINIMUM_PHP_VERSION, '>=')) { + add_action('admin_notices', [$this, 'admin_notice_minimum_php_version']); + return false; + } + + return true; + } + + /** + * Admin notice + * + * Warning when the site doesn't have Elementor installed or activated. + * + * @since 1.0.0 + * @access public + */ + public function admin_notice_missing_main_plugin() + { + if (isset($_GET['activate'])) unset($_GET['activate']); + + $message = sprintf( + /* translators: 1: Plugin name 2: Elementor */ + esc_html__('"%1$s" requires "%2$s" to be installed and activated.', 'academy-africa'), + '' . esc_html__('academyAfrica Elementor Addon', 'academy-africa') . '', + '' . esc_html__('Elementor', 'academy-africa') . '' + ); + + printf('

%1$s

', $message); + } + + /** + * Admin notice + * + * Warning when the site doesn't have a minimum required Elementor version. + * + * @since 1.0.0 + * @access public + */ + public function admin_notice_minimum_elementor_version() + { + if (isset($_GET['activate'])) unset($_GET['activate']); + + $message = sprintf( + /* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */ + esc_html__('"%1$s" requires "%2$s" version %3$s or greater.', 'academy-africa'), + '' . esc_html__('academyAfrica Elementor Addon', 'academy-africa') . '', + '' . esc_html__('Elementor', 'academy-africa') . '', + self::MINIMUM_ELEMENTOR_VERSION + ); + + printf('

%1$s

', $message); + } + + /** + * Admin notice + * + * Warning when the site doesn't have a minimum required PHP version. + * + * @since 1.0.0 + * @access public + */ + public function admin_notice_minimum_php_version() + { + if (isset($_GET['activate'])) unset($_GET['activate']); + + $message = sprintf( + /* translators: 1: Plugin name 2: PHP 3: Required PHP version */ + esc_html__('"%1$s" requires "%2$s" version %3$s or greater.', 'academy-africa'), + '' . esc_html__('academyAfrica Elementor Addon', 'academy-africa') . '', + '' . esc_html__('PHP', 'academy-africa') . '', + self::MINIMUM_PHP_VERSION + ); + + printf('

%1$s

', $message); + } + + /** + * Initialize the plugin + * + * Load the plugin only after Elementor (and other plugins) are loaded. + * + * @since 1.0.0 + * @access public + */ + + public function init() + { + + add_action('elementor/widgets/register', [$this, 'register_widgets']); + add_action('elementor/frontend/after_enqueue_styles', [$this, 'register_widget_styles']); + add_action('elementor/elements/categories_registered', [$this, 'add_elementor_widget_categories']); + } + + /** + * Include Widgets files + * + * Load widgets files + * + * @since 1.0.0 + * @access private + */ + public function register_widgets($widgets_manager) + { + // Include Widget files + require_once(__DIR__ . '/widgets/hero.php'); + require_once(__DIR__ . '/widgets/header.php'); + require_once(__DIR__ . '/widgets/footer.php'); + + // Register widget + $widgets_manager->register(new \Academy_Africa_Hero()); + $widgets_manager->register(new \Academy_Africa_Header()); + $widgets_manager->register(new \Academy_Africa_Footer()); + } + + public function register_widget_styles() + { + wp_enqueue_style( + 'academy-africa', + plugins_url('assets/css/academy-africa.css', __FILE__), + [], + [], + filemtime(plugin_dir_path(__FILE__) . 'assets/css/academy-africa.css.css') + ); + + wp_enqueue_style( + 'academy-africa-header', + plugins_url('assets/css/header.css', __FILE__), + [ + 'academy-africa' + ], + filemtime(plugin_dir_path(__FILE__) . 'assets/css/header.css') + ); + } + + /** + * Add custom category + * + * @since 1.0.0 + * @access public + */ + public function add_elementor_widget_categories($elements_manager){ + $elements_manager->add_category( + 'academy-africa', + [ + 'title' => __('Academy Africa', 'academy-africa'), + 'icon' => 'fa fa-plug', + ] + ); + } +} \ No newline at end of file diff --git a/wp-content/plugins/academy-africa/includes/widgets/footer.php b/wp-content/plugins/academy-africa/includes/widgets/footer.php new file mode 100644 index 00000000..ba73d67c --- /dev/null +++ b/wp-content/plugins/academy-africa/includes/widgets/footer.php @@ -0,0 +1,118 @@ + + + Date: Thu, 19 Oct 2023 19:04:25 +0300 Subject: [PATCH 2/6] Make footer UI editable --- .../includes/assets/css/footer.css | 16 +- .../academy-africa/includes/plugin.php | 23 +- .../includes/widgets/footer.php | 300 ++++++++++++------ 3 files changed, 224 insertions(+), 115 deletions(-) diff --git a/wp-content/plugins/academy-africa/includes/assets/css/footer.css b/wp-content/plugins/academy-africa/includes/assets/css/footer.css index adc13979..ed5ce422 100644 --- a/wp-content/plugins/academy-africa/includes/assets/css/footer.css +++ b/wp-content/plugins/academy-africa/includes/assets/css/footer.css @@ -41,6 +41,11 @@ margin-bottom: 60px; } +.root .item:nth-child(1) { + justify-content: flex-end; + padding-left: 100px; +} + .root .item:nth-child(2) { justify-content: flex-end; } @@ -82,7 +87,6 @@ } .root .site-description { - padding: 0 100px; display: flex; flex-direction: column; justify-content: space-between; @@ -164,8 +168,12 @@ } } -.root .links .secondary { +.root .links>.secondary~.secondary { margin-top: 10px; +} + +.root .links .secondary { + margin-top: 30px; color: var(--shades-white, #fff); font-family: Open Sans; font-size: 16px; @@ -175,8 +183,8 @@ display: inline-block; } -.root .links .secondary.first { - margin-top: 30px; +.root .links .secondary~ { + margin-top: 10px; } @media only screen and (max-width: 768px) { diff --git a/wp-content/plugins/academy-africa/includes/plugin.php b/wp-content/plugins/academy-africa/includes/plugin.php index 31e2b02a..e96d56a6 100644 --- a/wp-content/plugins/academy-africa/includes/plugin.php +++ b/wp-content/plugins/academy-africa/includes/plugin.php @@ -212,14 +212,7 @@ public function init() */ public function register_widgets($widgets_manager) { - // Include Widget files - require_once(__DIR__ . '/widgets/hero.php'); - require_once(__DIR__ . '/widgets/header.php'); require_once(__DIR__ . '/widgets/footer.php'); - - // Register widget - $widgets_manager->register(new \Academy_Africa_Hero()); - $widgets_manager->register(new \Academy_Africa_Header()); $widgets_manager->register(new \Academy_Africa_Footer()); } @@ -230,7 +223,7 @@ public function register_widget_styles() plugins_url('assets/css/academy-africa.css', __FILE__), [], [], - filemtime(plugin_dir_path(__FILE__) . 'assets/css/academy-africa.css.css') + filemtime(plugin_dir_path(__FILE__) . 'assets/css/academy-africa.css') ); wp_enqueue_style( @@ -241,6 +234,15 @@ public function register_widget_styles() ], filemtime(plugin_dir_path(__FILE__) . 'assets/css/header.css') ); + + wp_enqueue_style( + 'academy-africa-footer', + plugins_url('assets/css/footer.css', __FILE__), + [ + 'academy-africa' + ], + filemtime(plugin_dir_path(__FILE__) . 'assets/css/footer.css') + ); } /** @@ -249,7 +251,8 @@ public function register_widget_styles() * @since 1.0.0 * @access public */ - public function add_elementor_widget_categories($elements_manager){ + public function add_elementor_widget_categories($elements_manager) + { $elements_manager->add_category( 'academy-africa', [ @@ -258,4 +261,4 @@ public function add_elementor_widget_categories($elements_manager){ ] ); } -} \ No newline at end of file +} diff --git a/wp-content/plugins/academy-africa/includes/widgets/footer.php b/wp-content/plugins/academy-africa/includes/widgets/footer.php index ba73d67c..993e2dc9 100644 --- a/wp-content/plugins/academy-africa/includes/widgets/footer.php +++ b/wp-content/plugins/academy-africa/includes/widgets/footer.php @@ -1,118 +1,216 @@ - - + Date: Fri, 20 Oct 2023 07:27:50 +0300 Subject: [PATCH 3/6] update footer --- contrib/docker-compose/php/php.ini | 1 + docker-compose.yml | 1 + .../includes/assets/css/footer.css | 6 ++ ...=facebook, Size=24, Color=CurrentColor.svg | 3 + ...pe=github, Size=24, Color=CurrentColor.svg | 10 +++ ...instagram, Size=24, Color=CurrentColor.svg | 5 ++ ...=linkedin, Size=24, Color=CurrentColor.svg | 5 ++ ...ype=slack, Size=24, Color=CurrentColor.svg | 10 +++ ...e=twitter, Size=24, Color=CurrentColor.svg | 3 + .../includes/widgets/footer.php | 85 +++++++++++++++---- 10 files changed, 112 insertions(+), 17 deletions(-) create mode 100644 contrib/docker-compose/php/php.ini create mode 100644 wp-content/plugins/academy-africa/includes/assets/images/icons/Type=facebook, Size=24, Color=CurrentColor.svg create mode 100644 wp-content/plugins/academy-africa/includes/assets/images/icons/Type=github, Size=24, Color=CurrentColor.svg create mode 100644 wp-content/plugins/academy-africa/includes/assets/images/icons/Type=instagram, Size=24, Color=CurrentColor.svg create mode 100644 wp-content/plugins/academy-africa/includes/assets/images/icons/Type=linkedin, Size=24, Color=CurrentColor.svg create mode 100644 wp-content/plugins/academy-africa/includes/assets/images/icons/Type=slack, Size=24, Color=CurrentColor.svg create mode 100644 wp-content/plugins/academy-africa/includes/assets/images/icons/Type=twitter, Size=24, Color=CurrentColor.svg diff --git a/contrib/docker-compose/php/php.ini b/contrib/docker-compose/php/php.ini new file mode 100644 index 00000000..d01770f9 --- /dev/null +++ b/contrib/docker-compose/php/php.ini @@ -0,0 +1 @@ +allow_url_fopen: 1 diff --git a/docker-compose.yml b/docker-compose.yml index d5d6b1e5..1ea5cf15 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,4 +17,5 @@ services: - ./wp-content/themes:/var/www/html/wp-content/themes - ./wp-content/plugins:/var/www/html/wp-content/plugins - ./contrib/docker-compose/php/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini + - ./contrib/docker-compose/php/php.ini:/usr/local/etc/php/php.ini diff --git a/wp-content/plugins/academy-africa/includes/assets/css/footer.css b/wp-content/plugins/academy-africa/includes/assets/css/footer.css index ed5ce422..5a4358b1 100644 --- a/wp-content/plugins/academy-africa/includes/assets/css/footer.css +++ b/wp-content/plugins/academy-africa/includes/assets/css/footer.css @@ -1,3 +1,5 @@ +@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;400;500;600&display=swap"); + .body1, .root .links .primary, .root .embed #mc_embed_signup, @@ -168,6 +170,10 @@ } } +.root .links .icon { + color: var(--shades-white, #fff); +} + .root .links>.secondary~.secondary { margin-top: 10px; } diff --git a/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=facebook, Size=24, Color=CurrentColor.svg b/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=facebook, Size=24, Color=CurrentColor.svg new file mode 100644 index 00000000..3914b332 --- /dev/null +++ b/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=facebook, Size=24, Color=CurrentColor.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=github, Size=24, Color=CurrentColor.svg b/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=github, Size=24, Color=CurrentColor.svg new file mode 100644 index 00000000..33fc4f5f --- /dev/null +++ b/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=github, Size=24, Color=CurrentColor.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=instagram, Size=24, Color=CurrentColor.svg b/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=instagram, Size=24, Color=CurrentColor.svg new file mode 100644 index 00000000..2680211c --- /dev/null +++ b/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=instagram, Size=24, Color=CurrentColor.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=linkedin, Size=24, Color=CurrentColor.svg b/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=linkedin, Size=24, Color=CurrentColor.svg new file mode 100644 index 00000000..18e5c230 --- /dev/null +++ b/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=linkedin, Size=24, Color=CurrentColor.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=slack, Size=24, Color=CurrentColor.svg b/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=slack, Size=24, Color=CurrentColor.svg new file mode 100644 index 00000000..2f69259e --- /dev/null +++ b/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=slack, Size=24, Color=CurrentColor.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=twitter, Size=24, Color=CurrentColor.svg b/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=twitter, Size=24, Color=CurrentColor.svg new file mode 100644 index 00000000..cc56e409 --- /dev/null +++ b/wp-content/plugins/academy-africa/includes/assets/images/icons/Type=twitter, Size=24, Color=CurrentColor.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/plugins/academy-africa/includes/widgets/footer.php b/wp-content/plugins/academy-africa/includes/widgets/footer.php index 993e2dc9..7c689b2a 100644 --- a/wp-content/plugins/academy-africa/includes/widgets/footer.php +++ b/wp-content/plugins/academy-africa/includes/widgets/footer.php @@ -58,8 +58,26 @@ protected function register_controls() 'default' => __('', 'academy-africa'), ] ); + + $this->add_control( + 'stay_in_touch_text', + [ + 'label' => __('Stay in Touch', 'academy-africa'), + 'type' => \Elementor\Controls_Manager::TEXT, + 'default' => __('STAY IN TOUCH', 'academy-africa'), + ] + ); $links = new \Elementor\Repeater(); + $links->add_control( + 'label', + [ + 'label' => esc_html__('Label', 'academy-africa'), + 'type' => \Elementor\Controls_Manager::TEXT, + 'default' => 'Link Label', + ] + ); + $links->add_control( 'page_link', [ @@ -71,12 +89,42 @@ protected function register_controls() ] ); - $links->add_control( - 'label', + $social_media = new \Elementor\Repeater(); + $social_media->add_control( + 'type', [ - 'label' => esc_html__('Label', 'academy-africa'), - 'type' => \Elementor\Controls_Manager::TEXT, - 'default' => 'Link Label', + 'label' => esc_html__('Type', 'academy-africa'), + 'type' => \Elementor\Controls_Manager::SELECT, + 'default' => 'github', + 'options' => [ + 'facebook' => esc_html__('Facebook', 'academy-africa'), + 'github' => esc_html__('Github', 'academy-africa'), + 'slack' => esc_html__('Slack', 'academy-africa'), + 'linkedin' => esc_html__('LinkedIn', 'academy-africa'), + 'instagram' => esc_html__('Instagram', 'academy-africa'), + 'twitter' => esc_html__('Twitter', 'academy-africa'), + ] + ] + ); + + $social_media->add_control( + 'link', + [ + 'label' => esc_html__('Page Link', 'academy-africa'), + 'type' => \Elementor\Controls_Manager::URL, + 'default' => [ + 'url' => '', + ], + ] + ); + + $this->add_control( + 'social_media_links', + [ + 'label' => esc_html__('Social Media Links', 'academy-africa'), + 'type' => \Elementor\Controls_Manager::REPEATER, + 'fields' => $social_media->get_controls(), + 'title_field' => '{{{ type }}}', ] ); @@ -107,14 +155,6 @@ protected function register_controls() 'default' => __('Subscribe to the Code for Africa newsletter', 'academy-africa'), ] ); - $this->add_control( - 'stay_in_touch_text', - [ - 'label' => __('Stay in Touch', 'academy-africa'), - 'type' => \Elementor\Controls_Manager::TEXT, - 'default' => __('STAY IN TOUCH', 'academy-africa'), - ] - ); $this->add_control( 'newsletter_embed_code', [ @@ -173,9 +213,20 @@ protected function render()

-

get_render_attribute_string('stay_in_touch_text'); ?>> + get_render_attribute_string('stay_in_touch_text'); ?>> -

+ + ' . $content . ''; + } + } + ?>
@@ -201,9 +252,9 @@ protected function render()
-

get_render_attribute_string('newsletter_signup_text'); ?>> +

get_render_attribute_string('newsletter_signup_text'); ?>> -

+

get_render_attribute_string('newsletter_embed_code'); ?>>
From 259192a7b1e92c175ab0a8b9092665a4621aeca6 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Fri, 20 Oct 2023 08:49:23 +0300 Subject: [PATCH 4/6] Update footer --- .../plugins/academy-africa/includes/assets/css/footer.css | 1 - wp-content/plugins/academy-africa/includes/widgets/footer.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/wp-content/plugins/academy-africa/includes/assets/css/footer.css b/wp-content/plugins/academy-africa/includes/assets/css/footer.css index 5a4358b1..789ef2ed 100644 --- a/wp-content/plugins/academy-africa/includes/assets/css/footer.css +++ b/wp-content/plugins/academy-africa/includes/assets/css/footer.css @@ -1,4 +1,3 @@ -@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;400;500;600&display=swap"); .body1, .root .links .primary, diff --git a/wp-content/plugins/academy-africa/includes/widgets/footer.php b/wp-content/plugins/academy-africa/includes/widgets/footer.php index 7c689b2a..b861fc9f 100644 --- a/wp-content/plugins/academy-africa/includes/widgets/footer.php +++ b/wp-content/plugins/academy-africa/includes/widgets/footer.php @@ -223,7 +223,7 @@ protected function render() $type = esc_html($item['type']); $icon = dirname(plugin_dir_url(__FILE__)) . ('/assets/images/icons/Type=' . $type . ', Size=24, Color=CurrentColor.svg'); $content = file_get_contents($icon); - echo '' . $content . ''; + echo '' . $content . ''; } } ?> From ce4032201e81c9e622ade1ada761814ebc2e0632 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Thu, 26 Oct 2023 11:42:19 +0300 Subject: [PATCH 5/6] Deploy to dev tes on a different branch --- .github/workflows/deploy-to-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-to-dev.yml b/.github/workflows/deploy-to-dev.yml index 51ddcb3a..c435b981 100644 --- a/.github/workflows/deploy-to-dev.yml +++ b/.github/workflows/deploy-to-dev.yml @@ -2,7 +2,7 @@ name: Deploy to WP Engine on: push: branches: - - feature/setup-development-environment + - feature/globals-footer jobs: build: runs-on: ubuntu-latest From 2e66190f9389aa6b001c7a2f7005b7b31d423429 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Thu, 26 Oct 2023 13:21:53 +0300 Subject: [PATCH 6/6] Update footer --- wp-content/plugins/academy-africa/includes/widgets/footer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-content/plugins/academy-africa/includes/widgets/footer.php b/wp-content/plugins/academy-africa/includes/widgets/footer.php index b861fc9f..b7205c08 100644 --- a/wp-content/plugins/academy-africa/includes/widgets/footer.php +++ b/wp-content/plugins/academy-africa/includes/widgets/footer.php @@ -9,7 +9,7 @@ class Academy_Africa_Footer extends \Elementor\Widget_Base public function get_name() { - return 'footer'; + return 'Footer'; } public function get_style_depends() @@ -19,7 +19,7 @@ public function get_style_depends() public function get_title() { - return esc_html__('footer', 'elementor-footer-widget'); + return esc_html__('Footer'); } public function get_icon()