From 9bc4a018334edee1b563a0eda6e5c3fe92d45e06 Mon Sep 17 00:00:00 2001 From: GP_DV Date: Thu, 10 Apr 2025 11:07:01 +0300 Subject: [PATCH] Feat | add timber starter theme template --- .../themes/cosmopet-timber/.gitattributes | 4 + .../.github/PULL_REQUEST_TEMPLATE.md | 35 ++++ .../.github/workflows/test.yml | 76 +++++++ wp-content/themes/cosmopet-timber/.gitignore | 4 + wp-content/themes/cosmopet-timber/404.php | 11 ++ wp-content/themes/cosmopet-timber/LICENSE | 7 + wp-content/themes/cosmopet-timber/README.md | 36 ++++ wp-content/themes/cosmopet-timber/archive.php | 39 ++++ .../cosmopet-timber/assets/fonts/.gitkeep | 0 .../cosmopet-timber/assets/images/.gitkeep | 0 .../cosmopet-timber/assets/scripts/site.js | 5 + .../cosmopet-timber/assets/styles/.gitkeep | 0 wp-content/themes/cosmopet-timber/author.php | 18 ++ .../themes/cosmopet-timber/composer.json | 75 +++++++ .../themes/cosmopet-timber/functions.php | 19 ++ wp-content/themes/cosmopet-timber/humans.txt | 10 + wp-content/themes/cosmopet-timber/index.php | 27 +++ wp-content/themes/cosmopet-timber/page.php | 17 ++ .../themes/cosmopet-timber/phpcs.xml.dist | 32 +++ .../themes/cosmopet-timber/phpstan.neon | 15 ++ wp-content/themes/cosmopet-timber/phpunit.xml | 14 ++ .../themes/cosmopet-timber/screenshot.png | Bin 0 -> 13031 bytes wp-content/themes/cosmopet-timber/search.php | 18 ++ wp-content/themes/cosmopet-timber/single.php | 20 ++ .../cosmopet-timber/src/StarterSite.php | 186 ++++++++++++++++++ .../themes/cosmopet-timber/src/style.css | 5 + wp-content/themes/cosmopet-timber/style.css | 5 + .../cosmopet-timber/tests/bootstrap.php | 28 +++ .../tests/test-timber-starter-theme.php | 64 ++++++ .../cosmopet-timber/views/layouts/base.twig | 43 ++++ .../views/partials/comment-form.twig | 32 +++ .../views/partials/comment.twig | 19 ++ .../views/partials/footer.twig | 1 + .../cosmopet-timber/views/partials/head.twig | 9 + .../cosmopet-timber/views/partials/menu.twig | 12 ++ .../views/partials/pagination.twig | 44 +++++ .../views/partials/tease-post.twig | 16 ++ .../cosmopet-timber/views/partials/tease.twig | 9 + .../cosmopet-timber/views/templates/404.twig | 5 + .../views/templates/archive.twig | 15 ++ .../views/templates/author.twig | 7 + .../views/templates/index.twig | 16 ++ .../cosmopet-timber/views/templates/page.twig | 12 ++ .../views/templates/search.twig | 18 ++ .../views/templates/single-password.twig | 17 ++ .../views/templates/single.twig | 37 ++++ wp-content/themes/cosmopet/functions.php | 25 ++- .../global-functions/multilang-functions.php | 80 ++++---- .../themes/cosmopet/templates/layout.twig | 1 - .../themes/cosmopet/templates/shop/index.php | 1 + .../themes/cosmopet/templates/shop/shop.twig | 1 + .../cosmopet/woocommerce/archive-product.php | 40 ++++ .../archive-product/archive-product.twig | 12 ++ 53 files changed, 1198 insertions(+), 44 deletions(-) create mode 100644 wp-content/themes/cosmopet-timber/.gitattributes create mode 100644 wp-content/themes/cosmopet-timber/.github/PULL_REQUEST_TEMPLATE.md create mode 100644 wp-content/themes/cosmopet-timber/.github/workflows/test.yml create mode 100644 wp-content/themes/cosmopet-timber/.gitignore create mode 100644 wp-content/themes/cosmopet-timber/404.php create mode 100644 wp-content/themes/cosmopet-timber/LICENSE create mode 100644 wp-content/themes/cosmopet-timber/README.md create mode 100644 wp-content/themes/cosmopet-timber/archive.php create mode 100644 wp-content/themes/cosmopet-timber/assets/fonts/.gitkeep create mode 100644 wp-content/themes/cosmopet-timber/assets/images/.gitkeep create mode 100644 wp-content/themes/cosmopet-timber/assets/scripts/site.js create mode 100644 wp-content/themes/cosmopet-timber/assets/styles/.gitkeep create mode 100644 wp-content/themes/cosmopet-timber/author.php create mode 100644 wp-content/themes/cosmopet-timber/composer.json create mode 100644 wp-content/themes/cosmopet-timber/functions.php create mode 100644 wp-content/themes/cosmopet-timber/humans.txt create mode 100644 wp-content/themes/cosmopet-timber/index.php create mode 100644 wp-content/themes/cosmopet-timber/page.php create mode 100644 wp-content/themes/cosmopet-timber/phpcs.xml.dist create mode 100644 wp-content/themes/cosmopet-timber/phpstan.neon create mode 100644 wp-content/themes/cosmopet-timber/phpunit.xml create mode 100644 wp-content/themes/cosmopet-timber/screenshot.png create mode 100644 wp-content/themes/cosmopet-timber/search.php create mode 100644 wp-content/themes/cosmopet-timber/single.php create mode 100644 wp-content/themes/cosmopet-timber/src/StarterSite.php create mode 100644 wp-content/themes/cosmopet-timber/src/style.css create mode 100644 wp-content/themes/cosmopet-timber/style.css create mode 100644 wp-content/themes/cosmopet-timber/tests/bootstrap.php create mode 100644 wp-content/themes/cosmopet-timber/tests/test-timber-starter-theme.php create mode 100644 wp-content/themes/cosmopet-timber/views/layouts/base.twig create mode 100644 wp-content/themes/cosmopet-timber/views/partials/comment-form.twig create mode 100644 wp-content/themes/cosmopet-timber/views/partials/comment.twig create mode 100644 wp-content/themes/cosmopet-timber/views/partials/footer.twig create mode 100644 wp-content/themes/cosmopet-timber/views/partials/head.twig create mode 100644 wp-content/themes/cosmopet-timber/views/partials/menu.twig create mode 100644 wp-content/themes/cosmopet-timber/views/partials/pagination.twig create mode 100644 wp-content/themes/cosmopet-timber/views/partials/tease-post.twig create mode 100644 wp-content/themes/cosmopet-timber/views/partials/tease.twig create mode 100644 wp-content/themes/cosmopet-timber/views/templates/404.twig create mode 100644 wp-content/themes/cosmopet-timber/views/templates/archive.twig create mode 100644 wp-content/themes/cosmopet-timber/views/templates/author.twig create mode 100644 wp-content/themes/cosmopet-timber/views/templates/index.twig create mode 100644 wp-content/themes/cosmopet-timber/views/templates/page.twig create mode 100644 wp-content/themes/cosmopet-timber/views/templates/search.twig create mode 100644 wp-content/themes/cosmopet-timber/views/templates/single-password.twig create mode 100644 wp-content/themes/cosmopet-timber/views/templates/single.twig create mode 100644 wp-content/themes/cosmopet/woocommerce/archive-product.php create mode 100644 wp-content/themes/cosmopet/woocommerce/archive-product/archive-product.twig diff --git a/wp-content/themes/cosmopet-timber/.gitattributes b/wp-content/themes/cosmopet-timber/.gitattributes new file mode 100644 index 0000000..2e1912c --- /dev/null +++ b/wp-content/themes/cosmopet-timber/.gitattributes @@ -0,0 +1,4 @@ +/.gitattributes export-ignore +/.github export-ignore +/tests export-ignore +/phpunit.xml \ No newline at end of file diff --git a/wp-content/themes/cosmopet-timber/.github/PULL_REQUEST_TEMPLATE.md b/wp-content/themes/cosmopet-timber/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..626a6ed --- /dev/null +++ b/wp-content/themes/cosmopet-timber/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,35 @@ + + + + +Related: + +- Ticket 1 +- Ticket 2 + +## Issue + + + +## Solution + + + +## Impact + + + +## Usage Changes + + +## Considerations + + + +## Testing + diff --git a/wp-content/themes/cosmopet-timber/.github/workflows/test.yml b/wp-content/themes/cosmopet-timber/.github/workflows/test.yml new file mode 100644 index 0000000..f949e1e --- /dev/null +++ b/wp-content/themes/cosmopet-timber/.github/workflows/test.yml @@ -0,0 +1,76 @@ +name: Timber starter theme tests + +on: + push: + branches: + - '1.x' + - '2.x' + pull_request: + types: + - opened + - synchronize + - ready_for_review + +# Cancel previous workflow run groups that have not completed. +concurrency: + # Group workflow runs by workflow name, along with the head branch ref of the pull request + # or otherwise the branch or tag ref. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + phpunit: + runs-on: ubuntu-latest + + continue-on-error: ${{ matrix.experimental }} + strategy: + fail-fast: false + matrix: + php: ['8.1', '8.2'] + wp: ['latest'] + multisite: ['0', '1'] + extensions: ['gd'] + experimental: [false] + include: + # PHP 8.2 / experimental + - php: '8.2' + wp: 'trunk' + dependency-version: 'highest' + multisite: '0' + experimental: true + # PHP 8.3 / experimental + - php: '8.3' + wp: 'trunk' + dependency-version: 'highest' + multisite: '0' + experimental: true + # Coverage + - php: '8.1' + wp: 'latest' + dependency-version: 'highest' + multisite: '0' + experimental: false + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + extensions: curl, date, dom, iconv, json, libxml, gd + + - name: Setup problem matchers for PHP + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: Setup problem matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - uses: ramsey/composer-install@v3 + + - name: Run tests + run: composer run test + env: + WP_MULTISITE: ${{ matrix.multisite }} diff --git a/wp-content/themes/cosmopet-timber/.gitignore b/wp-content/themes/cosmopet-timber/.gitignore new file mode 100644 index 0000000..9477bf3 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/.gitignore @@ -0,0 +1,4 @@ +/composer.lock +/vendor/ +/wordpress/ +.phpunit.result.cache \ No newline at end of file diff --git a/wp-content/themes/cosmopet-timber/404.php b/wp-content/themes/cosmopet-timber/404.php new file mode 100644 index 0000000..a51168d --- /dev/null +++ b/wp-content/themes/cosmopet-timber/404.php @@ -0,0 +1,11 @@ + $title, + ] +); + +Timber::render( $templates, $context ); diff --git a/wp-content/themes/cosmopet-timber/assets/fonts/.gitkeep b/wp-content/themes/cosmopet-timber/assets/fonts/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/wp-content/themes/cosmopet-timber/assets/images/.gitkeep b/wp-content/themes/cosmopet-timber/assets/images/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/wp-content/themes/cosmopet-timber/assets/scripts/site.js b/wp-content/themes/cosmopet-timber/assets/scripts/site.js new file mode 100644 index 0000000..6655bd0 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/assets/scripts/site.js @@ -0,0 +1,5 @@ +jQuery( document ).ready( function( $ ) { + + // Your JavaScript goes here + +}); \ No newline at end of file diff --git a/wp-content/themes/cosmopet-timber/assets/styles/.gitkeep b/wp-content/themes/cosmopet-timber/assets/styles/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/wp-content/themes/cosmopet-timber/author.php b/wp-content/themes/cosmopet-timber/author.php new file mode 100644 index 0000000..dae48bc --- /dev/null +++ b/wp-content/themes/cosmopet-timber/author.php @@ -0,0 +1,18 @@ +name() ); +} + +Timber::render( [ 'templates/author.twig', 'templates/archive.twig' ], $context ); diff --git a/wp-content/themes/cosmopet-timber/composer.json b/wp-content/themes/cosmopet-timber/composer.json new file mode 100644 index 0000000..1e1dcd5 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/composer.json @@ -0,0 +1,75 @@ +{ + "name": "timber/starter-theme", + "description": "Starter theme to build a Timber theme", + "type":"wordpress-theme", + "license": "MIT", + "authors": [ + { + "name": "Erik van der Bas", + "email": "erik@basedonline.nl", + "homepage": "https://basedonline.nl" + }, + { + "name": "Lukas Gächter", + "email": "lukas.gaechter@mind.ch", + "homepage": "https://www.mind.ch" + }, + { + "name": "Nicolas Lemoine", + "email": "nico@n5s.dev", + "homepage": "https://n5s.dev" + }, + { + "name": "Jared Novack", + "email": "jared@upstatement.com", + "homepage": "https://upstatement.com" + }, + { + "name": "Timber Community", + "homepage": "https://github.com/timber/timber" + } + ], + "repositories": [ + { + "type": "composer", + "url": "https://wpackagist.org" + } + ], + "require": { + "timber/timber": "^2.1" + }, + "require-dev": { + "automattic/wordbless": "^0.4.2", + "yoast/wp-test-utils": "^1.0", + "wp-coding-standards/wpcs": "^3.1", + "phpcompatibility/php-compatibility": "^9", + "szepeviktor/phpstan-wordpress": "^1.3", + "10up/phpcs-composer": "^3.0" + }, + "extra": { + "installer-paths": { + "vendor/automattic/wordbless/": [ + "automattic/wordbless" + ] + }, + "wordpress-install-dir": "wordpress" + }, + "config": { + "allow-plugins": { + "roots/wordpress-core-installer": true, + "composer/installers": true, + "dealerdirect/phpcodesniffer-composer-installer": true + } + }, + "autoload": { + "psr-4": { + "App\\": "src/" + } + }, + "scripts": { + "test": "phpunit", + "cs": "@php ./vendor/bin/phpcs --colors -s -p -v ./", + "cs:fix": "@php ./vendor/bin/phpcbf --colors -s -p -v ./", + "phpstan": "@php ./vendor/bin/phpstan analyse" + } +} diff --git a/wp-content/themes/cosmopet-timber/functions.php b/wp-content/themes/cosmopet-timber/functions.php new file mode 100644 index 0000000..76890b8 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/functions.php @@ -0,0 +1,19 @@ + 'bar', + ] +); + +Timber::render( $templates, $context ); diff --git a/wp-content/themes/cosmopet-timber/page.php b/wp-content/themes/cosmopet-timber/page.php new file mode 100644 index 0000000..34c142d --- /dev/null +++ b/wp-content/themes/cosmopet-timber/page.php @@ -0,0 +1,17 @@ + + + + . + + */node_modules/* + */wordpress/* + */vendor/* + */resources/* + */dist/* + */tests/* + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wp-content/themes/cosmopet-timber/phpstan.neon b/wp-content/themes/cosmopet-timber/phpstan.neon new file mode 100644 index 0000000..5ce8f6d --- /dev/null +++ b/wp-content/themes/cosmopet-timber/phpstan.neon @@ -0,0 +1,15 @@ +parameters: + editorUrl: 'vscode://file/%%file%%:%%line%%' + level: 5 # Increase until "max" + paths: + - src/ + - %currentWorkingDirectory%/ + excludePaths: + - tests/* + - docs/* + - vendor/* + - wordpress/* + ignoreErrors: + +includes: + - vendor/szepeviktor/phpstan-wordpress/extension.neon \ No newline at end of file diff --git a/wp-content/themes/cosmopet-timber/phpunit.xml b/wp-content/themes/cosmopet-timber/phpunit.xml new file mode 100644 index 0000000..c0f40d4 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/phpunit.xml @@ -0,0 +1,14 @@ + + + + ./tests/ + + + diff --git a/wp-content/themes/cosmopet-timber/screenshot.png b/wp-content/themes/cosmopet-timber/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..f37bb02e9897506b4c9583768cec5bb74f5110bd GIT binary patch literal 13031 zcmdseby$>LyYHwV2oeg?B?!KNbPod3In>aNbPhQ*C?O)H(%l0ylynJ52-4jRGUU(< z4QG7c@7w46@tytu-gB`o*7MArYu)!+zZDaqt}0J}M}-Ff00{ID zm^a^_Fz{j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Z|TexUL{iSKI zPs9ZV%azA*S7Ic=gG31?=~H(Bd_hGG4u`*Y$V#r;Lnd#Y+|L-#7&3tbyrdSKsN?)} z!S_5dhDTM0>7FF6S2AgJCWr4PO$!U5#K~q-=@rvvNXEERmGc^~(X|j2M_^mEp8^SqQ5r^J=Rrv;YVJm6ycrKlZuH*uMtP;R*LK9k6Bk? zUG^#N`B=~W%{%4tONk_cX0em!ovL3u%|CSa3_P1tGdd`4V`BEzExtgLaPDPB5?Oo@ z)!f0;SAr%^k!J||FOwefZYVsGIuHA){`}PQ-oo`k)y-P7U{Dw<0X3(`ItxR?^XEMH^d1d;1^(85pO>XC&cg%~-L9~vPmd@;rt@$Kc#OjcB^ zD96@1F6nw6OT{^{+$SoZsoe^1t#S6|U!fWmKT%z|sp*C-9#-7G-r0BH!_1VE`&Q7~ zhL@%S`^l+U0jt9rOLEz#UsAJr%Q-2XDN}(G|-p z5w{EcBp;+X6v&C;XS+Jb&e{8Lkw|!*i}o7j5owlWQcKxCzQ#u?^p&SO@MJcgeLboE zgdD_uQ4}$R87b>Bm7Y4#7wspFbYN3HTUcAczr-Mw+JBpnu-On*x+-1dM8X zZ_j6-iHX3jEPdC<6O&i2z8Dt&{KrM%Y1^&PW<{>LTEVpz>TvY;Z-GkYrN}b&ydv%l z8h9jqXFp_q)1T($%b-^YKD)H6lDI;rgarP(5aXF~7d68Esjfxe@b^H6J4X5E3)OP@ zf4D9fkTFSp6k@#NM^ecX#r&i*=(4)UKnMUx~#&OQ?o2OUYOml9- zX^#c(<X-6V!x$_)ohW9FA3o)@@96yK+G?>x$$i|KDUV%glYFi5ob`B9OcQfU zn0U%t4i|IZ^4|ZNg7qA8C-#3&dB=c-xwZR0ub2tnnZCORnDJx)!m}ge{`~YrQC3x^ JOv)_y{{Xml4yXVC literal 0 HcmV?d00001 diff --git a/wp-content/themes/cosmopet-timber/search.php b/wp-content/themes/cosmopet-timber/search.php new file mode 100644 index 0000000..9e1ac5f --- /dev/null +++ b/wp-content/themes/cosmopet-timber/search.php @@ -0,0 +1,18 @@ + 'Search results for ' . get_search_query(), + ] +); + +Timber::render( $templates, $context ); diff --git a/wp-content/themes/cosmopet-timber/single.php b/wp-content/themes/cosmopet-timber/single.php new file mode 100644 index 0000000..df070cf --- /dev/null +++ b/wp-content/themes/cosmopet-timber/single.php @@ -0,0 +1,20 @@ +post_type . '.twig', 'templates/single.twig' ]; + +if ( post_password_required( $post->ID ) ) { + $templates = 'templates/single-password.twig'; +} + +Timber::render( $templates, $context ); diff --git a/wp-content/themes/cosmopet-timber/src/StarterSite.php b/wp-content/themes/cosmopet-timber/src/StarterSite.php new file mode 100644 index 0000000..834eaad --- /dev/null +++ b/wp-content/themes/cosmopet-timber/src/StarterSite.php @@ -0,0 +1,186 @@ + _x( 'Main menu', 'Backend - menu name', 'timber-starter' ), + ] + ); + + // Add default posts and comments RSS feed links to head. + add_theme_support( 'automatic-feed-links' ); + + /* + * Let WordPress manage the document title. + * By adding theme support, we declare that this theme does not use a + * hard-coded tag in the document head, and expect WordPress to + * provide it for us. + */ + add_theme_support( 'title-tag' ); + + /* + * Enable support for Post Thumbnails on posts and pages. + * + * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ + */ + add_theme_support( 'post-thumbnails' ); + + /* + * Switch default core markup for search form, comment form, and comments + * to output valid HTML5. + */ + add_theme_support( + 'html5', + [ + 'comment-form', + 'comment-list', + 'gallery', + 'caption', + ] + ); + + /* + * Enable support for Post Formats. + * + * See: https://codex.wordpress.org/Post_Formats + */ + add_theme_support( + 'post-formats', + [ + 'aside', + 'image', + 'video', + 'quote', + 'link', + 'gallery', + 'audio', + ] + ); + + add_theme_support( 'menus' ); + } + + /** + * This would return 'foo bar!'. + * + * @param string $text being 'foo', then returned 'foo bar!' + */ + public function myfoo( $text ) { + $text .= ' bar!'; + + return $text; + } + + /** + * This is where you can add your own functions to twig. + * + * @link https://timber.github.io/docs/v2/hooks/filters/#timber/twig/filters + * @param array $filters an array of Twig filters. + */ + public function add_filters_to_twig( $filters ) { + + $additional_filters = [ + 'myfoo' => [ + 'callable' => [ $this, 'myfoo' ], + ], + ]; + + return array_merge( $filters, $additional_filters ); + } + + + /** + * This is where you can add your own functions to twig. + * + * @link https://timber.github.io/docs/v2/hooks/filters/#timber/twig/functions + * @param array $functions an array of existing Twig functions. + */ + public function add_functions_to_twig( $functions ) { + $additional_functions = [ + 'get_theme_mod' => [ + 'callable' => 'get_theme_mod', + ], + ]; + + return array_merge( $functions, $additional_functions ); + } + + /** + * Updates Twig environment options. + * + * @see https://twig.symfony.com/doc/2.x/api.html#environment-options + * + * @param array $options an array of environment options + * + * @return array + */ + public function update_twig_environment_options( $options ) { + // $options['autoescape'] = true; + + return $options; + } +} diff --git a/wp-content/themes/cosmopet-timber/src/style.css b/wp-content/themes/cosmopet-timber/src/style.css new file mode 100644 index 0000000..e7b0324 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/src/style.css @@ -0,0 +1,5 @@ +/* + * Theme Name: Cosmopet Theme + * Description: Boilerplate Theme for Cosmopet site + * Author: Good Production +*/ \ No newline at end of file diff --git a/wp-content/themes/cosmopet-timber/style.css b/wp-content/themes/cosmopet-timber/style.css new file mode 100644 index 0000000..e8aa430 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/style.css @@ -0,0 +1,5 @@ +/* + * Theme Name: Cosmopet Theme + * Description: Boilerplate Theme for Cosmopet site + * Author: Good Production +*/ diff --git a/wp-content/themes/cosmopet-timber/tests/bootstrap.php b/wp-content/themes/cosmopet-timber/tests/bootstrap.php new file mode 100644 index 0000000..fb3f982 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/tests/bootstrap.php @@ -0,0 +1,28 @@ +<?php + +use WorDBless\Load; + +if (! file_exists(dirname(__DIR__) . '/wordpress/wp-content')) { + mkdir(dirname(__DIR__) . '/wordpress/wp-content'); +} + +if (! file_exists(dirname(__DIR__) . '/wordpress/wp-content/themes')) { + mkdir(dirname(__DIR__) . '/wordpress/wp-content/themes'); +} + +copy( + dirname(__DIR__) . '/vendor/automattic/wordbless/src/dbless-wpdb.php', + dirname(__DIR__) . '/wordpress/wp-content/db.php' +); + +$theme_base_name = basename(dirname(__DIR__)); +$src = realpath(dirname(dirname(__DIR__)) . '/' . $theme_base_name); +$dest = dirname(__DIR__) . '/wordpress/wp-content/themes/' . $theme_base_name; + +if ( is_dir($src) && ! file_exists($dest) ) { + symlink($src, $dest); +} + +require_once dirname(__DIR__) . '/vendor/autoload.php'; + +Load::load(); diff --git a/wp-content/themes/cosmopet-timber/tests/test-timber-starter-theme.php b/wp-content/themes/cosmopet-timber/tests/test-timber-starter-theme.php new file mode 100644 index 0000000..6f02aa4 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/tests/test-timber-starter-theme.php @@ -0,0 +1,64 @@ +<?php + +use Timber\Timber; +use WorDBless\BaseTestCase; + +class TestTimberStarterTheme extends BaseTestCase +{ + + public function set_up() + { + switch_theme(basename(dirname(__DIR__)) . '/theme'); + + require dirname(__DIR__) . '/functions.php'; + + Timber::$dirname = array_merge((array) Timber::$dirname, ['../views']); + Timber::$dirname = array_unique(Timber::$dirname); + + // WorDBless includes wp-settings.php + do_action('after_setup_theme'); + + parent::set_up(); + } + + function tear_down() + { + parent::tear_down(); + switch_theme('twentytwenty'); + } + + function testTimberExists() + { + $context = Timber::context(); + $this->assertTrue(is_array($context)); + } + + function testFunctionsPHP() + { + $context = Timber::context(); + $this->assertEquals('App\StarterSite', get_class($context['site'])); + $this->assertTrue(current_theme_supports('post-thumbnails')); + $this->assertEquals('bar', $context['foo']); + } + + function testLoading() + { + $str = Timber::compile('partials/tease.twig'); + $this->assertStringStartsWith('<article class="tease tease-" id="tease-">', $str); + $this->assertStringEndsWith('</article>', $str); + } + + /** + * Helper test to output current twig version + */ + function testTwigVersion() + { + $version = Timber::compile_string("{{ version }}", ['version' => Twig\Environment::VERSION]); + $this->assertEquals(Twig\Environment::VERSION, $version); + } + + // function testTwigFilter() { + // $str = Timber::compile_string('{{ "foo"|myfoo }}'); + // $this->assertEquals('foo bar!', $str); + // } +} diff --git a/wp-content/themes/cosmopet-timber/views/layouts/base.twig b/wp-content/themes/cosmopet-timber/views/layouts/base.twig new file mode 100644 index 0000000..537c08d --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/layouts/base.twig @@ -0,0 +1,43 @@ +<!DOCTYPE html> +<html {{ site.language_attributes }}> + {% block head %} + {% include 'partials/head.twig' %} + {% endblock %} + + <body class="{{ body_class }}"> + {{ function('wp_body_open') }} + <a class="skip-link screen-reader-text" href="#content">{{ _e('Skip to content') }}</a> + <header class="header"> + {% block header %} + <div class="wrapper"> + <h1 class="hdr-logo"> + <a class="hdr-logo-link" href="{{ site.url }}">{{ site.name }}</a> + </h1> + <nav id="nav-main" class="nav-main"> + {% include 'partials/menu.twig' with { + items: menu.get_items + } %} + </nav> + <!-- #nav --> + </div> + {% endblock %} + </header> + + <section id="content" class="content-wrapper"> + {% if title %} + <h1>{{ title }}</h1> + {% endif %} + <div class="wrapper"> + {% block content %} + Sorry, no content + {% endblock %} + </div> + </section> + + {% block footer %} + {% include 'partials/footer.twig' %} + {% endblock %} + {{ function('wp_footer') }} + {% do action('get_footer') %} + </body> +</html> diff --git a/wp-content/themes/cosmopet-timber/views/partials/comment-form.twig b/wp-content/themes/cosmopet-timber/views/partials/comment-form.twig new file mode 100644 index 0000000..565f4b6 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/partials/comment-form.twig @@ -0,0 +1,32 @@ +<div class="comment-form"> + <h3>Add comment</h3> + <form class="comment-form" method="post" action="{{ site.link ~ '/wp-comments-post.php' }}"> + {% if user %} + <input type="hidden" name="email" value="{{ user.email }}" /> + <input type="hidden" name="author" value="{{ user.name }}" /> + <input type="hidden" name="url" value="{{ user.link }}" /> + {% else %} + <label> + Email<br /> + <input required name="email" type="email" id="email" /> + </label> + <label> + Name<br /> + <input required name="author" type="text" /> + </label> + <label> + Website<br /> + <input name="url" type="url" /> + </label> + {% endif %} + <label> + Comment<br /> + <textarea placeholder="Leave a comment..." name="comment" cols="60" rows="3"></textarea> + </label> + <input name="comment_post_ID" value="{{ post.id }}" type="hidden" /> + <input name="comment_parent" value="{{ comment.id|default('0') }}" type="hidden" /> + <button type="submit" name="Submit" class="btn">Send</button> + <button type="reset">Cancel</button> + <p>Your comment will be revised by the site if needed.</p> + </form> +</div> diff --git a/wp-content/themes/cosmopet-timber/views/partials/comment.twig b/wp-content/themes/cosmopet-timber/views/partials/comment.twig new file mode 100644 index 0000000..710f979 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/partials/comment.twig @@ -0,0 +1,19 @@ +<div class="blog-comment" id="blog-comment-{{ comment.id }}"> + <h5 class="comment-author">{{ comment.author.name }} says</h5> + <div class="comment-content">{{ comment.content|wpautop }}</div> + + <section class="comment-box"> + {% include 'partials/comment-form.twig' %} + + {% if post.comments %} + <h4>replies</h4> + <div class="comments"> + {% for cmt in comment.children %} + {% include 'partials/comment.twig' with { + comment: cmt + } %} + {% endfor %} + </div> + {% endif %} + </section> +</div> diff --git a/wp-content/themes/cosmopet-timber/views/partials/footer.twig b/wp-content/themes/cosmopet-timber/views/partials/footer.twig new file mode 100644 index 0000000..606165c --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/partials/footer.twig @@ -0,0 +1 @@ +<footer id="footer">Copyright {{ 'now'|date('Y') }}</footer> diff --git a/wp-content/themes/cosmopet-timber/views/partials/head.twig b/wp-content/themes/cosmopet-timber/views/partials/head.twig new file mode 100644 index 0000000..ea68c2a --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/partials/head.twig @@ -0,0 +1,9 @@ +<head> + <meta charset="{{ site.charset }}" /> + <link rel="stylesheet" href="{{ site.theme.link }}/style.css" type="text/css" media="screen" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <link rel="author" href="{{ site.theme.link }}/humans.txt" /> + <link rel="profile" href="http://gmpg.org/xfn/11" /> + {% do action('get_header') %} + {{ function('wp_head') }} +</head> diff --git a/wp-content/themes/cosmopet-timber/views/partials/menu.twig b/wp-content/themes/cosmopet-timber/views/partials/menu.twig new file mode 100644 index 0000000..377dc98 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/partials/menu.twig @@ -0,0 +1,12 @@ +{% if menu %} + <ul> + {% for item in items %} + <li class="{{ item.classes|join(' ') }}"> + <a target="{{ item.target }}" href="{{ item.link }}">{{ item.title }}</a> + {% include 'partials/menu.twig' with { + items: item.children + } %} + </li> + {% endfor %} + </ul> +{% endif %} diff --git a/wp-content/themes/cosmopet-timber/views/partials/pagination.twig b/wp-content/themes/cosmopet-timber/views/partials/pagination.twig new file mode 100644 index 0000000..e4d737b --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/partials/pagination.twig @@ -0,0 +1,44 @@ +{% if posts.pagination.pages is not empty %} + <nav class="pagination-block"> + <ul class="pagination"> + {# First #} + {% if (posts.pagination.pages|first) and posts.pagination.pages|first.current != true %} + <li class="first btn"> + <a href="{{ posts.pagination.pages|first.link }}">First</a> + </li> + {% else %} + <li class="first btn disabled"><button disabled>First</button></li> + {% endif %} + + {# Previous #} + {% if posts.pagination.prev %} + <li class="prev btn"><a href="{{ posts.pagination.prev.link }}">Previous</a></li> + {% else %} + <li class="prev btn disabled"><button disabled>Previous</button></li> + {% endif %} + + {# Pages #} + {% for page in posts.pagination.pages %} + {% if page.link %} + <li><a href="{{ page.link }}" class="{{ page.class }}">{{ page.title }}</a></li> + {% else %} + <li class="current"><span class="{{ page.class }}">{{ page.title }}</span></li> + {% endif %} + {% endfor %} + + {# Next #} + {% if posts.pagination.next %} + <li class="next btn"><a href="{{ posts.pagination.next.link }}">Next</a></li> + {% else %} + <li class="next btn disabled"><button disabled>Next</button></li> + {% endif %} + + {# Last #} + {% if (posts.pagination.pages|last) and posts.pagination.pages|last.current != true %} + <li class="last btn"><a href="{{ posts.pagination.pages|last.link }}">Last</a></li> + {% else %} + <li class="last btn disabled"><button disabled>Last</button></li> + {% endif %} + </ul> + </nav> +{% endif %} diff --git a/wp-content/themes/cosmopet-timber/views/partials/tease-post.twig b/wp-content/themes/cosmopet-timber/views/partials/tease-post.twig new file mode 100644 index 0000000..5a08767 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/partials/tease-post.twig @@ -0,0 +1,16 @@ +{% extends 'partials/tease.twig' %} + +{% block content %} + <h2 class="h2"><a href="{{ post.link }}">{{ post.title }}</a></h2> + <p> + {{ + post.excerpt({ + words: 5, + read_more: 'Keep reading' + }) + }} + </p> + {% if post.thumbnail.src %} + <img src="{{ post.thumbnail.src }}" /> + {% endif %} +{% endblock %} diff --git a/wp-content/themes/cosmopet-timber/views/partials/tease.twig b/wp-content/themes/cosmopet-timber/views/partials/tease.twig new file mode 100644 index 0000000..1a0f7b0 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/partials/tease.twig @@ -0,0 +1,9 @@ +<article class="tease tease-{{ post.type }}" id="tease-{{ post.id }}"> + {% block content %} + <h2 class="h2"><a href="{{ post.link }}">{{ post.title }}</a></h2> + <p>{{ post.excerpt }}</p> + {% if post.thumbnail %} + <img src="{{ post.thumbnail.src }}" /> + {% endif %} + {% endblock %} +</article> \ No newline at end of file diff --git a/wp-content/themes/cosmopet-timber/views/templates/404.twig b/wp-content/themes/cosmopet-timber/views/templates/404.twig new file mode 100644 index 0000000..1b2073c --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/templates/404.twig @@ -0,0 +1,5 @@ +{% extends 'layouts/base.twig' %} + +{% block content %} + Sorry, we couldn't find what you're looking for. +{% endblock %} diff --git a/wp-content/themes/cosmopet-timber/views/templates/archive.twig b/wp-content/themes/cosmopet-timber/views/templates/archive.twig new file mode 100644 index 0000000..ae021ea --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/templates/archive.twig @@ -0,0 +1,15 @@ +{% extends 'layouts/base.twig' %} + +{% block content %} + {% for post in posts %} + {% include ['partials/tease-' ~ post.type ~ '.twig', 'partials/tease.twig'] %} + {% endfor %} + + {% include 'partials/pagination.twig' with { + pagination: posts.pagination({ + show_all: false, + mid_size: 3, + end_size: 2 + }) + } %} +{% endblock %} diff --git a/wp-content/themes/cosmopet-timber/views/templates/author.twig b/wp-content/themes/cosmopet-timber/views/templates/author.twig new file mode 100644 index 0000000..6d19761 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/templates/author.twig @@ -0,0 +1,7 @@ +{% extends 'layouts/base.twig' %} + +{% block content %} + {% for post in posts %} + {% include ['partials/tease-' ~ post.type ~ '.twig', 'partials/tease.twig'] %} + {% endfor %} +{% endblock %} diff --git a/wp-content/themes/cosmopet-timber/views/templates/index.twig b/wp-content/themes/cosmopet-timber/views/templates/index.twig new file mode 100644 index 0000000..b68fbd7 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/templates/index.twig @@ -0,0 +1,16 @@ +{% extends 'layouts/base.twig' %} + +{% block content %} + <h2>{{ foo }}</h2> + {% for post in posts %} + {% include ['partials/tease-' ~ post.type ~ '.twig', 'partials/tease.twig'] %} + {% endfor %} + + {% include 'partials/pagination.twig' with { + pagination: posts.pagination({ + show_all: false, + mid_size: 3, + end_size: 2 + }) + } %} +{% endblock %} diff --git a/wp-content/themes/cosmopet-timber/views/templates/page.twig b/wp-content/themes/cosmopet-timber/views/templates/page.twig new file mode 100644 index 0000000..7709c52 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/templates/page.twig @@ -0,0 +1,12 @@ +{% extends 'layouts/base.twig' %} + +{% block content %} + <div class="content-wrapper"> + <article class="post-type-{{ post.type }}" id="post-{{ post.id }}"> + <section class="article-content"> + <h1 class="article-h1">{{ post.title }}</h1> + <div class="article-body">{{ post.content }}</div> + </section> + </article> + </div> +{% endblock %} diff --git a/wp-content/themes/cosmopet-timber/views/templates/search.twig b/wp-content/themes/cosmopet-timber/views/templates/search.twig new file mode 100644 index 0000000..f8853a6 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/templates/search.twig @@ -0,0 +1,18 @@ +{# see `templates/archive.twig` for an alternative strategy of extending templates #} +{% extends 'layouts/base.twig' %} + +{% block content %} + <div class="content-wrapper"> + {% for post in posts %} + {% include ['partials/tease-' ~ post.type ~ '.twig', 'partials/tease.twig'] %} + {% endfor %} + + {% include 'partials/pagination.twig' with { + pagination: posts.pagination({ + show_all: false, + mid_size: 3, + end_size: 2 + }) + } %} + </div> +{% endblock %} diff --git a/wp-content/themes/cosmopet-timber/views/templates/single-password.twig b/wp-content/themes/cosmopet-timber/views/templates/single-password.twig new file mode 100644 index 0000000..fc62761 --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/templates/single-password.twig @@ -0,0 +1,17 @@ +{% extends 'layouts/base.twig' %} + +{% block content %} + <form class="password-form" + action="{{ site.link }}/wp-login.php?action=postpass" + method="post"> + <label for="pwbox-{{ post.id }}">Password:</label> + <input class="password-box" + name="post_password" + id="pwbox-{{ post.id }}" + type="password" + placeholder="Password" + size="20" + maxlength="20" /> + <input class="password-btn" type="submit" name="Submit" value="Submit" /> + </form> +{% endblock %} diff --git a/wp-content/themes/cosmopet-timber/views/templates/single.twig b/wp-content/themes/cosmopet-timber/views/templates/single.twig new file mode 100644 index 0000000..584450d --- /dev/null +++ b/wp-content/themes/cosmopet-timber/views/templates/single.twig @@ -0,0 +1,37 @@ +{% extends 'layouts/base.twig' %} + +{% block content %} + <div class="content-wrapper"> + <article class="post-type-{{ post.type }}" id="post-{{ post.id }}"> + <img src="{{ post.thumbnail.src|resize(1200, 300) }}" /> + <section class="article-content"> + <h1 class="article-h1">{{ post.title }}</h1> + <p class="blog-author"> + <span>By</span> + <a href="{{ post.author.path }}">{{ post.author.name }}</a> + <span>•</span> + <time datetime="{{ post.date|date('Y-m-d H:i:s') }}">{{ post.date }}</time> + </p> + <div class="article-body">{{ post.content }}</div> + </section> + <section class="comment-box"> + <div class="comments"> + {% if post.comments %} + <h3>comments</h3> + {% for cmt in post.comments %} + {% include 'partials/comment.twig' with { + comment: cmt + } %} + {% endfor %} + {% endif %} + </div> + + {% if post.comment_status == 'closed' %} + <p>comments for this post are closed</p> + {% else %} + {% include 'partials/comment-form.twig' %} + {% endif %} + </section> + </article> + </div> +{% endblock %} diff --git a/wp-content/themes/cosmopet/functions.php b/wp-content/themes/cosmopet/functions.php index c178e1b..e38e470 100644 --- a/wp-content/themes/cosmopet/functions.php +++ b/wp-content/themes/cosmopet/functions.php @@ -14,7 +14,12 @@ Timber::$dirname = [ ], ]; +function theme_add_woocommerce_support() +{ + add_theme_support('woocommerce'); +} +add_action('after_setup_theme', 'theme_add_woocommerce_support'); add_theme_support('post-thumbnails'); //Подруключение всех ajax controller если запрос сделан по ajax @@ -365,14 +370,26 @@ function enqueue_static_assets($dir_name, $options = []) { } } + +add_action('init', function() { + if (function_exists('wpseo_load_textdomain')) { + wpseo_load_textdomain(); + } + if (function_exists('pll_load_textdomain')) { + pll_load_textdomain(); + } + add_filter('timber/context', function($context) { + $context['current_lang'] = pll_current_language(); + return $context; + }); +}, 1); + + $modules_path = get_template_directory() . '/modules/*/editor-blocks/*/editor-block-controller.php'; foreach (glob($modules_path) as $file) { require_once $file; // Подключаем каждый найденный файл } -add_filter('timber/context', function($context) { - $context['current_lang'] = pll_current_language(); - return $context; -}); + requireShortcodes(get_template_directory() . '/modules'); diff --git a/wp-content/themes/cosmopet/global-functions/multilang-functions.php b/wp-content/themes/cosmopet/global-functions/multilang-functions.php index cff45b2..98d131e 100644 --- a/wp-content/themes/cosmopet/global-functions/multilang-functions.php +++ b/wp-content/themes/cosmopet/global-functions/multilang-functions.php @@ -1,41 +1,43 @@ <?php +add_action('init', function() { + pll_register_string ('Темы', 'Темы'); + pll_register_string ('САМЫЕ ЧИТАЕМЫЕ', 'САМЫЕ ЧИТАЕМЫЕ'); + pll_register_string ('время чтения', 'время чтения'); + pll_register_string ('ВСЕ СТАТЬИ', 'ВСЕ СТАТЬИ'); + pll_register_string ('ПРЕДЛОЖИТЕ СТАТЬЮ ИЛИ СТАНЬТЕ АВТОРОМ', 'ПРЕДЛОЖИТЕ СТАТЬЮ ИЛИ СТАНЬТЕ АВТОРОМ'); + pll_register_string ('НАПИШИТЕ НАМ', 'НАПИШИТЕ НАМ'); + pll_register_string ('COSMO тема редакции', 'COSMO тема редакции'); + pll_register_string ('мин.', 'мин.'); + pll_register_string ('Форма обратной связи', 'Форма обратной связи'); + pll_register_string ('Ваше имя', 'Ваше имя'); + pll_register_string ('Эл.почта', 'Эл.почта'); + pll_register_string ('Текст обращения', 'Текст обращения'); + pll_register_string ('Отправить', 'Отправить'); + pll_register_string ('Чат бот с ветеринаром', 'Чат бот с ветеринаром'); + pll_register_string ('Калькулятор рациона', 'Калькулятор рациона'); + pll_register_string ('ПОКАЗАТЬ ЕЩЁ', 'ПОКАЗАТЬ ЕЩЁ'); + pll_register_string ('ВСЕ', 'ВСЕ'); + pll_register_string ('читать статью', 'читать статью'); + pll_register_string ('Блог', 'Блог'); + pll_register_string ('Главная', 'Главная'); + pll_register_string ('Подпишитесь, чтобы быть в курсе деятельности Cosmopet и узнавать о наших, предложениях. Обещаем не заваливать вас бесполезными письмами. А за подписку дарим -25% на весь ассортимент нашей продукции', 'Подпишитесь, чтобы быть в курсе деятельности Cosmopet и узнавать о наших предложениях. Обещаем не заваливать вас бесполезными письмами. А за подписку дарим -25% на весь ассортимент нашей продукции'); + pll_register_string ('Подписываясь на рассылку, я даю согласие на обработку персональных данных, на получение рекламных сообщений и новостей о товарах и услугах', 'Подписываясь на рассылку, я даю согласие на обработку персональных данных, на получение рекламных сообщений и новостей о товарах и услугах'); + pll_register_string ('подписаться', 'подписаться'); + pll_register_string ('Узнайте о нас больше и получите <span>скидку!</span>', 'Узнайте о нас больше и получите <span>скидку!</span>'); + pll_register_string ('Это миф!', 'Это миф!'); + pll_register_string ('Это правда!', 'Это правда!'); + pll_register_string ('Правда', 'Правда'); + pll_register_string ('Миф', 'Миф'); + pll_register_string ('Далее', 'Далее'); + pll_register_string ('ваш результат', 'ваш результат'); + pll_register_string ('Скопировать', 'Скопировать'); + pll_register_string ('Скопировано', 'Скопировано'); + pll_register_string ('В магазин', 'В магазин'); + pll_register_string ('Наш блог', 'Наш блог'); + pll_register_string ('Новости рынка кормов и экологии, полезные статьи о здоровье домашних животных', 'Новости рынка кормов и экологии, полезные статьи о здоровье домашних животных'); + pll_register_string ('ЭТАПЫ ПРОИЗВОД­СТВА', 'ЭТАПЫ ПРОИЗВОД­СТВА'); + pll_register_string ('Этапы производс­тва корма', 'Этапы производс­тва корма'); + pll_register_string ('Все статьи', 'Все статьи'); + pll_register_string ('Узнать больше', 'Узнать больше'); +}); -pll_register_string ('Темы', 'Темы'); -pll_register_string ('САМЫЕ ЧИТАЕМЫЕ', 'САМЫЕ ЧИТАЕМЫЕ'); -pll_register_string ('время чтения', 'время чтения'); -pll_register_string ('ВСЕ СТАТЬИ', 'ВСЕ СТАТЬИ'); -pll_register_string ('ПРЕДЛОЖИТЕ СТАТЬЮ ИЛИ СТАНЬТЕ АВТОРОМ', 'ПРЕДЛОЖИТЕ СТАТЬЮ ИЛИ СТАНЬТЕ АВТОРОМ'); -pll_register_string ('НАПИШИТЕ НАМ', 'НАПИШИТЕ НАМ'); -pll_register_string ('COSMO тема редакции', 'COSMO тема редакции'); -pll_register_string ('мин.', 'мин.'); -pll_register_string ('Форма обратной связи', 'Форма обратной связи'); -pll_register_string ('Ваше имя', 'Ваше имя'); -pll_register_string ('Эл.почта', 'Эл.почта'); -pll_register_string ('Текст обращения', 'Текст обращения'); -pll_register_string ('Отправить', 'Отправить'); -pll_register_string ('Чат бот с ветеринаром', 'Чат бот с ветеринаром'); -pll_register_string ('Калькулятор рациона', 'Калькулятор рациона'); -pll_register_string ('ПОКАЗАТЬ ЕЩЁ', 'ПОКАЗАТЬ ЕЩЁ'); -pll_register_string ('ВСЕ', 'ВСЕ'); -pll_register_string ('читать статью', 'читать статью'); -pll_register_string ('Блог', 'Блог'); -pll_register_string ('Главная', 'Главная'); -pll_register_string ('Подпишитесь, чтобы быть в курсе деятельности Cosmopet и узнавать о наших, предложениях. Обещаем не заваливать вас бесполезными письмами. А за подписку дарим -25% на весь ассортимент нашей продукции', 'Подпишитесь, чтобы быть в курсе деятельности Cosmopet и узнавать о наших предложениях. Обещаем не заваливать вас бесполезными письмами. А за подписку дарим -25% на весь ассортимент нашей продукции'); -pll_register_string ('Подписываясь на рассылку, я даю согласие на обработку персональных данных, на получение рекламных сообщений и новостей о товарах и услугах', 'Подписываясь на рассылку, я даю согласие на обработку персональных данных, на получение рекламных сообщений и новостей о товарах и услугах'); -pll_register_string ('подписаться', 'подписаться'); -pll_register_string ('Узнайте о нас больше и получите <span>скидку!</span>', 'Узнайте о нас больше и получите <span>скидку!</span>'); -pll_register_string ('Это миф!', 'Это миф!'); -pll_register_string ('Это правда!', 'Это правда!'); -pll_register_string ('Правда', 'Правда'); -pll_register_string ('Миф', 'Миф'); -pll_register_string ('Далее', 'Далее'); -pll_register_string ('ваш результат', 'ваш результат'); -pll_register_string ('Скопировать', 'Скопировать'); -pll_register_string ('Скопировано', 'Скопировано'); -pll_register_string ('В магазин', 'В магазин'); -pll_register_string ('Наш блог', 'Наш блог'); -pll_register_string ('Новости рынка кормов и экологии, полезные статьи о здоровье домашних животных', 'Новости рынка кормов и экологии, полезные статьи о здоровье домашних животных'); -pll_register_string ('ЭТАПЫ ПРОИЗВОД­СТВА', 'ЭТАПЫ ПРОИЗВОД­СТВА'); -pll_register_string ('Этапы производс­тва корма', 'Этапы производс­тва корма'); -pll_register_string ('Все статьи', 'Все статьи'); -pll_register_string ('Узнать больше', 'Узнать больше'); diff --git a/wp-content/themes/cosmopet/templates/layout.twig b/wp-content/themes/cosmopet/templates/layout.twig index 1a88a14..1938e5b 100644 --- a/wp-content/themes/cosmopet/templates/layout.twig +++ b/wp-content/themes/cosmopet/templates/layout.twig @@ -13,7 +13,6 @@ {% include 'header.twig' %} - <main> {% block content %} {% endblock %} diff --git a/wp-content/themes/cosmopet/templates/shop/index.php b/wp-content/themes/cosmopet/templates/shop/index.php index e69de29..d800886 100644 --- a/wp-content/themes/cosmopet/templates/shop/index.php +++ b/wp-content/themes/cosmopet/templates/shop/index.php @@ -0,0 +1 @@ +123 \ No newline at end of file diff --git a/wp-content/themes/cosmopet/templates/shop/shop.twig b/wp-content/themes/cosmopet/templates/shop/shop.twig index e69de29..d800886 100644 --- a/wp-content/themes/cosmopet/templates/shop/shop.twig +++ b/wp-content/themes/cosmopet/templates/shop/shop.twig @@ -0,0 +1 @@ +123 \ No newline at end of file diff --git a/wp-content/themes/cosmopet/woocommerce/archive-product.php b/wp-content/themes/cosmopet/woocommerce/archive-product.php new file mode 100644 index 0000000..bf7423d --- /dev/null +++ b/wp-content/themes/cosmopet/woocommerce/archive-product.php @@ -0,0 +1,40 @@ +<?php + +// function get_blog_posts_data() { +// // $args = array( +// // 'post_type' => 'post', +// // 'posts_per_page' => 6, +// // ); + +// // $posts = new WP_Query($args); +// $formatted_posts = array(); + +// if (have_posts()) { +// while (have_posts()) { +// the_post(); + +// $formatted_post = array( +// 'title' => get_the_title(), +// 'link' => get_permalink(), +// 'excerpt' => get_the_excerpt(), +// 'thumbnail' => has_post_thumbnail() +// ? get_the_post_thumbnail_url(get_the_ID(), 'full') +// : get_template_directory_uri() . "/static/front-page/img/blog_card-img.jpg" +// ); + +// $formatted_posts[] = $formatted_post; +// } +// wp_reset_postdata(); +// } + +// return $formatted_posts; + // } + + $context = Timber::get_context(); + $context['posts'] = Timber::get_posts(); + + + + Timber::render('archive-product/archive-product.twig', $context); + +?> \ No newline at end of file diff --git a/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product.twig b/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product.twig new file mode 100644 index 0000000..7760521 --- /dev/null +++ b/wp-content/themes/cosmopet/woocommerce/archive-product/archive-product.twig @@ -0,0 +1,12 @@ +{% set bodyClass = 'main-np' %} +{% extends 'layout.twig' %} + + +{% block content %} + +{% for post in posts %} + {{ post.title }} + +{% endfor %} + +{% endblock %} \ No newline at end of file