├── .github └── workflows │ └── deploy.yml ├── .gitignore ├── .wordpress-org ├── banner-1544x500.png ├── banner-772x250.jpg └── icon-256x256.png ├── README.md ├── composer.json ├── composer.lock ├── includes ├── class-gamajo-dashboard-glancer.php ├── class-gamajo-post-type.php ├── class-gamajo-single-entry-term-body-classes.php ├── class-gamajo-taxonomy.php ├── class-portfolio-post-type-admin.php ├── class-portfolio-post-type-post-type.php ├── class-portfolio-post-type-registrations.php ├── class-portfolio-post-type-taxonomy-category.php ├── class-portfolio-post-type-taxonomy-tag.php ├── class-portfolio-post-type.php └── interface-gamajo-registerable.php ├── languages ├── portfolio-post-type-pt_PT.mo ├── portfolio-post-type-pt_PT.po ├── portfolio-post-type-sv_SE.mo ├── portfolio-post-type-sv_SE.po └── portfolio-post-type.pot ├── phpcs.xml ├── phpunit.xml.dist ├── portfolio-post-type.php ├── readme.txt └── tests ├── bootstrap.php ├── integration ├── PortfolioRegistrationsTest.php └── PortfolioTaxonomiesTest.php └── unit ├── GamajoPostTypeTest.php ├── PortfolioAdminTest.php ├── PortfolioPostTypeUnitTest.php ├── PortfolioTaxonomyCategoryUnitTest.php └── PortfolioTaxonomyTagUnitTest.php /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy to WordPress.org 2 | on: 3 | release: 4 | types: [published] 5 | jobs: 6 | tag: 7 | name: New release 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout code 11 | uses: actions/checkout@v2 12 | - name: WordPress Plugin Deploy 13 | id: deploy 14 | uses: 10up/action-wordpress-plugin-deploy@stable 15 | with: 16 | generate-zip: true 17 | env: 18 | SVN_USERNAME: ${{ secrets.SVN_USERNAME }} 19 | SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} 20 | - name: Upload release asset 21 | uses: actions/upload-release-asset@v1 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | with: 25 | upload_url: ${{ github.event.release.upload_url }} 26 | asset_path: ${{ steps.deploy.outputs.zip-path }} 27 | asset_name: ${{ github.event.repository.name }}.zip 28 | asset_content_type: application/zip 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | .DS_Store 3 | Icon 4 | 5 | # Composer 6 | vendor 7 | .phpcs-cache -------------------------------------------------------------------------------- /.wordpress-org/banner-1544x500.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinsays/portfolio-post-type/42c9fd29660640867898e01323b6f74303145bf9/.wordpress-org/banner-1544x500.png -------------------------------------------------------------------------------- /.wordpress-org/banner-772x250.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinsays/portfolio-post-type/42c9fd29660640867898e01323b6f74303145bf9/.wordpress-org/banner-772x250.jpg -------------------------------------------------------------------------------- /.wordpress-org/icon-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinsays/portfolio-post-type/42c9fd29660640867898e01323b6f74303145bf9/.wordpress-org/icon-256x256.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Portfolio Post Type 2 | 3 | WordPress plugin that adds support for Portfolio entries. 4 | 5 | ## Description 6 | 7 | This plugin registers a custom post type for portfolio items. It also registers separate portfolio taxonomies for tags and categories. If featured images are selected, they will be displayed in the column view. 8 | 9 | This plugin doesn't change how portfolio items are displayed in your theme. You will need to add templates for `archive-portfolio.php` and `single-portfolio.php` if you want to customize the display of portfolio items. 10 | 11 | ## Requirements 12 | 13 | - WordPress 3.8, tested up to 6.4.1 14 | 15 | ## Installation 16 | 17 | ### Upload 18 | 19 | 1. Download the latest tagged archive (choose the "zip" option). 20 | 2. Go to the **Plugins -> Add New** screen and click the **Upload** tab. 21 | 3. Upload the zipped archive directly. 22 | 4. Go to the Plugins screen and click **Activate**. 23 | 24 | ### Manual 25 | 26 | 1. Download the latest tagged archive (choose the "zip" option). 27 | 2. Unzip the archive. 28 | 3. Copy the folder to your `/wp-content/plugins/` directory. 29 | 4. Go to the Plugins screen and click **Activate**. 30 | 31 | Check out the Codex for more information about [installing plugins manually](http://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation). 32 | 33 | ### Git 34 | 35 | Using git, browse to your `/wp-content/plugins/` directory and clone this repository: 36 | 37 | `git clone https://github.com/devinsays/portfolio-post-type.git` 38 | 39 | Then go to your Plugins screen and click **Activate**. 40 | 41 | ## Customization 42 | 43 | Since the custom post type and two taxonomies have filterable arguments, it's possible to amend the labels or other arguments via a plugin or a theme. For example, to change the label from _Portfolio_ to _Projects_, you can do: 44 | 45 | ```php 46 | add_filter( 'portfolioposttype_args', 'prefix_change_portfolio_labels' ); 47 | /** 48 | * Change post type labels and arguments for Portfolio Post Type plugin. 49 | * 50 | * @param array $args Existing arguments. 51 | * 52 | * @return array Amended arguments. 53 | */ 54 | function prefix_change_portfolio_labels( array $args ) { 55 | $labels = array( 56 | 'name' => __( 'Projects', 'portfolioposttype' ), 57 | 'singular_name' => __( 'Project', 'portfolioposttype' ), 58 | 'add_new' => __( 'Add New Item', 'portfolioposttype' ), 59 | 'add_new_item' => __( 'Add New Project', 'portfolioposttype' ), 60 | 'edit_item' => __( 'Edit Project', 'portfolioposttype' ), 61 | 'new_item' => __( 'Add New Project', 'portfolioposttype' ), 62 | 'view_item' => __( 'View Item', 'portfolioposttype' ), 63 | 'search_items' => __( 'Search Projects', 'portfolioposttype' ), 64 | 'not_found' => __( 'No projects found', 'portfolioposttype' ), 65 | 'not_found_in_trash' => __( 'No projects found in trash', 'portfolioposttype' ), 66 | ); 67 | $args['labels'] = $labels; 68 | 69 | // Update project single permalink format, and archive slug as well. 70 | $args['rewrite'] = array( 'slug' => 'project' ); 71 | $args['has_archive'] = true; 72 | // Don't forget to visit Settings->Permalinks after changing these to flush the rewrite rules. 73 | 74 | return $args; 75 | } 76 | ``` 77 | 78 | You'd likely want to do something similar with the labels for portfolio tag and portfolio category taxonomies as well. 79 | 80 | ## Frequently Asked Questions 81 | 82 | ### How can I display portfolio items differently than regular posts? 83 | 84 | You will need to get your hands dirty with a little code and create an `archive-portfolio.php` template (for displaying multiple items) and a `single-portfolio.php` (for displaying the single item). 85 | 86 | ### Why did you make this? 87 | 88 | To allow users of Portfolio Press to more easily migrate to a new theme. And hopefully, to save some work for other folks trying to create a portfolio. 89 | 90 | ### Is this plugin on the WordPress repo? 91 | 92 | Yes, you can find it here: [https://wordpress.org/plugins/portfolio-post-type/](https://wordpress.org/plugins/portfolio-post-type/) 93 | 94 | ## Credits 95 | 96 | Built by [Devin Price](https://www.wptheming.com/) and [Gary Jones](https://gamajo.com/) 97 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "devinsays/portfolio-post-type", 3 | "description": "", 4 | "keywords": [ "wordpress" ], 5 | "type": "wordpress-plugin", 6 | "homepage": "https://github.com/devinsays/portfolio-post-type", 7 | "license": "GPL-2.0+", 8 | "authors": [ 9 | { 10 | "name": "Devin Price", 11 | "homepage": "https://devpress.com" 12 | } 13 | ], 14 | "support": { 15 | "issues": "https://github.com/devinsays/portfolio-post-type/issues", 16 | "source": "https://github.com/devinsays/portfolio-post-type" 17 | }, 18 | "require-dev": { 19 | "automattic/vipwpcs": "^2.3", 20 | "dealerdirect/phpcodesniffer-composer-installer": "^0.7.2", 21 | "wp-cli/i18n-command": "^2.2.5" 22 | }, 23 | "scripts": { 24 | "make-pot": "wp i18n make-pot . languages/portfolio-post-type.pot" 25 | }, 26 | "config": { 27 | "allow-plugins": { 28 | "dealerdirect/phpcodesniffer-composer-installer": true 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "daf8433f3a61e02e805d5a45897f6cbc", 8 | "packages": [], 9 | "packages-dev": [ 10 | { 11 | "name": "automattic/vipwpcs", 12 | "version": "2.3.3", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/Automattic/VIP-Coding-Standards.git", 16 | "reference": "6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/Automattic/VIP-Coding-Standards/zipball/6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b", 21 | "reference": "6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7", 26 | "php": ">=5.4", 27 | "sirbrillig/phpcs-variable-analysis": "^2.11.1", 28 | "squizlabs/php_codesniffer": "^3.5.5", 29 | "wp-coding-standards/wpcs": "^2.3" 30 | }, 31 | "require-dev": { 32 | "php-parallel-lint/php-console-highlighter": "^0.5", 33 | "php-parallel-lint/php-parallel-lint": "^1.0", 34 | "phpcompatibility/php-compatibility": "^9", 35 | "phpcsstandards/phpcsdevtools": "^1.0", 36 | "phpunit/phpunit": "^4 || ^5 || ^6 || ^7" 37 | }, 38 | "type": "phpcodesniffer-standard", 39 | "notification-url": "https://packagist.org/downloads/", 40 | "license": [ 41 | "MIT" 42 | ], 43 | "authors": [ 44 | { 45 | "name": "Contributors", 46 | "homepage": "https://github.com/Automattic/VIP-Coding-Standards/graphs/contributors" 47 | } 48 | ], 49 | "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress VIP minimum coding conventions", 50 | "keywords": [ 51 | "phpcs", 52 | "standards", 53 | "wordpress" 54 | ], 55 | "support": { 56 | "issues": "https://github.com/Automattic/VIP-Coding-Standards/issues", 57 | "source": "https://github.com/Automattic/VIP-Coding-Standards", 58 | "wiki": "https://github.com/Automattic/VIP-Coding-Standards/wiki" 59 | }, 60 | "time": "2021-09-29T16:20:23+00:00" 61 | }, 62 | { 63 | "name": "dealerdirect/phpcodesniffer-composer-installer", 64 | "version": "v0.7.2", 65 | "source": { 66 | "type": "git", 67 | "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", 68 | "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" 69 | }, 70 | "dist": { 71 | "type": "zip", 72 | "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", 73 | "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", 74 | "shasum": "" 75 | }, 76 | "require": { 77 | "composer-plugin-api": "^1.0 || ^2.0", 78 | "php": ">=5.3", 79 | "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" 80 | }, 81 | "require-dev": { 82 | "composer/composer": "*", 83 | "php-parallel-lint/php-parallel-lint": "^1.3.1", 84 | "phpcompatibility/php-compatibility": "^9.0" 85 | }, 86 | "type": "composer-plugin", 87 | "extra": { 88 | "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" 89 | }, 90 | "autoload": { 91 | "psr-4": { 92 | "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" 93 | } 94 | }, 95 | "notification-url": "https://packagist.org/downloads/", 96 | "license": [ 97 | "MIT" 98 | ], 99 | "authors": [ 100 | { 101 | "name": "Franck Nijhof", 102 | "email": "franck.nijhof@dealerdirect.com", 103 | "homepage": "http://www.frenck.nl", 104 | "role": "Developer / IT Manager" 105 | }, 106 | { 107 | "name": "Contributors", 108 | "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" 109 | } 110 | ], 111 | "description": "PHP_CodeSniffer Standards Composer Installer Plugin", 112 | "homepage": "http://www.dealerdirect.com", 113 | "keywords": [ 114 | "PHPCodeSniffer", 115 | "PHP_CodeSniffer", 116 | "code quality", 117 | "codesniffer", 118 | "composer", 119 | "installer", 120 | "phpcbf", 121 | "phpcs", 122 | "plugin", 123 | "qa", 124 | "quality", 125 | "standard", 126 | "standards", 127 | "style guide", 128 | "stylecheck", 129 | "tests" 130 | ], 131 | "support": { 132 | "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", 133 | "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" 134 | }, 135 | "time": "2022-02-04T12:51:07+00:00" 136 | }, 137 | { 138 | "name": "eftec/bladeone", 139 | "version": "3.52", 140 | "source": { 141 | "type": "git", 142 | "url": "https://github.com/EFTEC/BladeOne.git", 143 | "reference": "a19bf66917de0b29836983db87a455a4f6e32148" 144 | }, 145 | "dist": { 146 | "type": "zip", 147 | "url": "https://api.github.com/repos/EFTEC/BladeOne/zipball/a19bf66917de0b29836983db87a455a4f6e32148", 148 | "reference": "a19bf66917de0b29836983db87a455a4f6e32148", 149 | "shasum": "" 150 | }, 151 | "require": { 152 | "ext-json": "*", 153 | "php": ">=5.6" 154 | }, 155 | "require-dev": { 156 | "friendsofphp/php-cs-fixer": "^2.16.1", 157 | "phpunit/phpunit": "^5.7", 158 | "squizlabs/php_codesniffer": "^3.5.4" 159 | }, 160 | "suggest": { 161 | "eftec/bladeonehtml": "Extension to create forms", 162 | "ext-mbstring": "This extension is used if it's active" 163 | }, 164 | "type": "library", 165 | "autoload": { 166 | "psr-4": { 167 | "eftec\\bladeone\\": "lib/" 168 | } 169 | }, 170 | "notification-url": "https://packagist.org/downloads/", 171 | "license": [ 172 | "MIT" 173 | ], 174 | "authors": [ 175 | { 176 | "name": "Jorge Patricio Castro Castillo", 177 | "email": "jcastro@eftec.cl" 178 | } 179 | ], 180 | "description": "The standalone version Blade Template Engine from Laravel in a single php file", 181 | "homepage": "https://github.com/EFTEC/BladeOne", 182 | "keywords": [ 183 | "blade", 184 | "php", 185 | "template", 186 | "templating", 187 | "view" 188 | ], 189 | "support": { 190 | "issues": "https://github.com/EFTEC/BladeOne/issues", 191 | "source": "https://github.com/EFTEC/BladeOne/tree/3.52" 192 | }, 193 | "time": "2021-04-17T13:49:01+00:00" 194 | }, 195 | { 196 | "name": "gettext/gettext", 197 | "version": "v4.8.8", 198 | "source": { 199 | "type": "git", 200 | "url": "https://github.com/php-gettext/Gettext.git", 201 | "reference": "302a00aa9d6762c92c884d879c15d3ed05d6a37d" 202 | }, 203 | "dist": { 204 | "type": "zip", 205 | "url": "https://api.github.com/repos/php-gettext/Gettext/zipball/302a00aa9d6762c92c884d879c15d3ed05d6a37d", 206 | "reference": "302a00aa9d6762c92c884d879c15d3ed05d6a37d", 207 | "shasum": "" 208 | }, 209 | "require": { 210 | "gettext/languages": "^2.3", 211 | "php": ">=5.4.0" 212 | }, 213 | "require-dev": { 214 | "illuminate/view": "^5.0.x-dev", 215 | "phpunit/phpunit": "^4.8|^5.7|^6.5", 216 | "squizlabs/php_codesniffer": "^3.0", 217 | "symfony/yaml": "~2", 218 | "twig/extensions": "*", 219 | "twig/twig": "^1.31|^2.0" 220 | }, 221 | "suggest": { 222 | "illuminate/view": "Is necessary if you want to use the Blade extractor", 223 | "symfony/yaml": "Is necessary if you want to use the Yaml extractor/generator", 224 | "twig/extensions": "Is necessary if you want to use the Twig extractor", 225 | "twig/twig": "Is necessary if you want to use the Twig extractor" 226 | }, 227 | "type": "library", 228 | "autoload": { 229 | "psr-4": { 230 | "Gettext\\": "src" 231 | } 232 | }, 233 | "notification-url": "https://packagist.org/downloads/", 234 | "license": [ 235 | "MIT" 236 | ], 237 | "authors": [ 238 | { 239 | "name": "Oscar Otero", 240 | "email": "oom@oscarotero.com", 241 | "homepage": "http://oscarotero.com", 242 | "role": "Developer" 243 | } 244 | ], 245 | "description": "PHP gettext manager", 246 | "homepage": "https://github.com/oscarotero/Gettext", 247 | "keywords": [ 248 | "JS", 249 | "gettext", 250 | "i18n", 251 | "mo", 252 | "po", 253 | "translation" 254 | ], 255 | "support": { 256 | "email": "oom@oscarotero.com", 257 | "issues": "https://github.com/oscarotero/Gettext/issues", 258 | "source": "https://github.com/php-gettext/Gettext/tree/v4.8.8" 259 | }, 260 | "funding": [ 261 | { 262 | "url": "https://paypal.me/oscarotero", 263 | "type": "custom" 264 | }, 265 | { 266 | "url": "https://github.com/oscarotero", 267 | "type": "github" 268 | }, 269 | { 270 | "url": "https://www.patreon.com/misteroom", 271 | "type": "patreon" 272 | } 273 | ], 274 | "time": "2022-12-08T11:59:50+00:00" 275 | }, 276 | { 277 | "name": "gettext/languages", 278 | "version": "2.10.0", 279 | "source": { 280 | "type": "git", 281 | "url": "https://github.com/php-gettext/Languages.git", 282 | "reference": "4d61d67fe83a2ad85959fe6133d6d9ba7dddd1ab" 283 | }, 284 | "dist": { 285 | "type": "zip", 286 | "url": "https://api.github.com/repos/php-gettext/Languages/zipball/4d61d67fe83a2ad85959fe6133d6d9ba7dddd1ab", 287 | "reference": "4d61d67fe83a2ad85959fe6133d6d9ba7dddd1ab", 288 | "shasum": "" 289 | }, 290 | "require": { 291 | "php": ">=5.3" 292 | }, 293 | "require-dev": { 294 | "phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.4" 295 | }, 296 | "bin": [ 297 | "bin/export-plural-rules" 298 | ], 299 | "type": "library", 300 | "autoload": { 301 | "psr-4": { 302 | "Gettext\\Languages\\": "src/" 303 | } 304 | }, 305 | "notification-url": "https://packagist.org/downloads/", 306 | "license": [ 307 | "MIT" 308 | ], 309 | "authors": [ 310 | { 311 | "name": "Michele Locati", 312 | "email": "mlocati@gmail.com", 313 | "role": "Developer" 314 | } 315 | ], 316 | "description": "gettext languages with plural rules", 317 | "homepage": "https://github.com/php-gettext/Languages", 318 | "keywords": [ 319 | "cldr", 320 | "i18n", 321 | "internationalization", 322 | "l10n", 323 | "language", 324 | "languages", 325 | "localization", 326 | "php", 327 | "plural", 328 | "plural rules", 329 | "plurals", 330 | "translate", 331 | "translations", 332 | "unicode" 333 | ], 334 | "support": { 335 | "issues": "https://github.com/php-gettext/Languages/issues", 336 | "source": "https://github.com/php-gettext/Languages/tree/2.10.0" 337 | }, 338 | "funding": [ 339 | { 340 | "url": "https://paypal.me/mlocati", 341 | "type": "custom" 342 | }, 343 | { 344 | "url": "https://github.com/mlocati", 345 | "type": "github" 346 | } 347 | ], 348 | "time": "2022-10-18T15:00:10+00:00" 349 | }, 350 | { 351 | "name": "mck89/peast", 352 | "version": "v1.15.1", 353 | "source": { 354 | "type": "git", 355 | "url": "https://github.com/mck89/peast.git", 356 | "reference": "cf06286910b7efc9dce7503553ebee314df3d3d3" 357 | }, 358 | "dist": { 359 | "type": "zip", 360 | "url": "https://api.github.com/repos/mck89/peast/zipball/cf06286910b7efc9dce7503553ebee314df3d3d3", 361 | "reference": "cf06286910b7efc9dce7503553ebee314df3d3d3", 362 | "shasum": "" 363 | }, 364 | "require": { 365 | "ext-mbstring": "*", 366 | "php": ">=5.4.0" 367 | }, 368 | "require-dev": { 369 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" 370 | }, 371 | "type": "library", 372 | "extra": { 373 | "branch-alias": { 374 | "dev-master": "1.15.1-dev" 375 | } 376 | }, 377 | "autoload": { 378 | "psr-4": { 379 | "Peast\\": "lib/Peast/", 380 | "Peast\\test\\": "test/Peast/" 381 | } 382 | }, 383 | "notification-url": "https://packagist.org/downloads/", 384 | "license": [ 385 | "BSD-3-Clause" 386 | ], 387 | "authors": [ 388 | { 389 | "name": "Marco Marchiò", 390 | "email": "marco.mm89@gmail.com" 391 | } 392 | ], 393 | "description": "Peast is PHP library that generates AST for JavaScript code", 394 | "support": { 395 | "issues": "https://github.com/mck89/peast/issues", 396 | "source": "https://github.com/mck89/peast/tree/v1.15.1" 397 | }, 398 | "time": "2023-01-21T13:18:17+00:00" 399 | }, 400 | { 401 | "name": "mustache/mustache", 402 | "version": "v2.14.2", 403 | "source": { 404 | "type": "git", 405 | "url": "https://github.com/bobthecow/mustache.php.git", 406 | "reference": "e62b7c3849d22ec55f3ec425507bf7968193a6cb" 407 | }, 408 | "dist": { 409 | "type": "zip", 410 | "url": "https://api.github.com/repos/bobthecow/mustache.php/zipball/e62b7c3849d22ec55f3ec425507bf7968193a6cb", 411 | "reference": "e62b7c3849d22ec55f3ec425507bf7968193a6cb", 412 | "shasum": "" 413 | }, 414 | "require": { 415 | "php": ">=5.2.4" 416 | }, 417 | "require-dev": { 418 | "friendsofphp/php-cs-fixer": "~1.11", 419 | "phpunit/phpunit": "~3.7|~4.0|~5.0" 420 | }, 421 | "type": "library", 422 | "autoload": { 423 | "psr-0": { 424 | "Mustache": "src/" 425 | } 426 | }, 427 | "notification-url": "https://packagist.org/downloads/", 428 | "license": [ 429 | "MIT" 430 | ], 431 | "authors": [ 432 | { 433 | "name": "Justin Hileman", 434 | "email": "justin@justinhileman.info", 435 | "homepage": "http://justinhileman.com" 436 | } 437 | ], 438 | "description": "A Mustache implementation in PHP.", 439 | "homepage": "https://github.com/bobthecow/mustache.php", 440 | "keywords": [ 441 | "mustache", 442 | "templating" 443 | ], 444 | "support": { 445 | "issues": "https://github.com/bobthecow/mustache.php/issues", 446 | "source": "https://github.com/bobthecow/mustache.php/tree/v2.14.2" 447 | }, 448 | "time": "2022-08-23T13:07:01+00:00" 449 | }, 450 | { 451 | "name": "rmccue/requests", 452 | "version": "v1.8.1", 453 | "source": { 454 | "type": "git", 455 | "url": "https://github.com/WordPress/Requests.git", 456 | "reference": "82e6936366eac3af4d836c18b9d8c31028fe4cd5" 457 | }, 458 | "dist": { 459 | "type": "zip", 460 | "url": "https://api.github.com/repos/WordPress/Requests/zipball/82e6936366eac3af4d836c18b9d8c31028fe4cd5", 461 | "reference": "82e6936366eac3af4d836c18b9d8c31028fe4cd5", 462 | "shasum": "" 463 | }, 464 | "require": { 465 | "php": ">=5.2" 466 | }, 467 | "require-dev": { 468 | "dealerdirect/phpcodesniffer-composer-installer": "^0.7", 469 | "php-parallel-lint/php-console-highlighter": "^0.5.0", 470 | "php-parallel-lint/php-parallel-lint": "^1.3", 471 | "phpcompatibility/php-compatibility": "^9.0", 472 | "phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5", 473 | "requests/test-server": "dev-master", 474 | "squizlabs/php_codesniffer": "^3.5", 475 | "wp-coding-standards/wpcs": "^2.0" 476 | }, 477 | "type": "library", 478 | "autoload": { 479 | "psr-0": { 480 | "Requests": "library/" 481 | } 482 | }, 483 | "notification-url": "https://packagist.org/downloads/", 484 | "license": [ 485 | "ISC" 486 | ], 487 | "authors": [ 488 | { 489 | "name": "Ryan McCue", 490 | "homepage": "http://ryanmccue.info" 491 | } 492 | ], 493 | "description": "A HTTP library written in PHP, for human beings.", 494 | "homepage": "http://github.com/WordPress/Requests", 495 | "keywords": [ 496 | "curl", 497 | "fsockopen", 498 | "http", 499 | "idna", 500 | "ipv6", 501 | "iri", 502 | "sockets" 503 | ], 504 | "support": { 505 | "issues": "https://github.com/WordPress/Requests/issues", 506 | "source": "https://github.com/WordPress/Requests/tree/v1.8.1" 507 | }, 508 | "time": "2021-06-04T09:56:25+00:00" 509 | }, 510 | { 511 | "name": "sirbrillig/phpcs-variable-analysis", 512 | "version": "v2.11.16", 513 | "source": { 514 | "type": "git", 515 | "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", 516 | "reference": "dc5582dc5a93a235557af73e523c389aac9a8e88" 517 | }, 518 | "dist": { 519 | "type": "zip", 520 | "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/dc5582dc5a93a235557af73e523c389aac9a8e88", 521 | "reference": "dc5582dc5a93a235557af73e523c389aac9a8e88", 522 | "shasum": "" 523 | }, 524 | "require": { 525 | "php": ">=5.4.0", 526 | "squizlabs/php_codesniffer": "^3.5.6" 527 | }, 528 | "require-dev": { 529 | "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.0", 530 | "phpcsstandards/phpcsdevcs": "^1.1", 531 | "phpstan/phpstan": "^1.7", 532 | "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.5 || ^7.0 || ^8.0 || ^9.0", 533 | "sirbrillig/phpcs-import-detection": "^1.1", 534 | "vimeo/psalm": "^0.2 || ^0.3 || ^1.1 || ^4.24 || ^5.0@beta" 535 | }, 536 | "type": "phpcodesniffer-standard", 537 | "autoload": { 538 | "psr-4": { 539 | "VariableAnalysis\\": "VariableAnalysis/" 540 | } 541 | }, 542 | "notification-url": "https://packagist.org/downloads/", 543 | "license": [ 544 | "BSD-2-Clause" 545 | ], 546 | "authors": [ 547 | { 548 | "name": "Sam Graham", 549 | "email": "php-codesniffer-variableanalysis@illusori.co.uk" 550 | }, 551 | { 552 | "name": "Payton Swick", 553 | "email": "payton@foolord.com" 554 | } 555 | ], 556 | "description": "A PHPCS sniff to detect problems with variables.", 557 | "keywords": [ 558 | "phpcs", 559 | "static analysis" 560 | ], 561 | "support": { 562 | "issues": "https://github.com/sirbrillig/phpcs-variable-analysis/issues", 563 | "source": "https://github.com/sirbrillig/phpcs-variable-analysis", 564 | "wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki" 565 | }, 566 | "time": "2023-03-31T16:46:32+00:00" 567 | }, 568 | { 569 | "name": "squizlabs/php_codesniffer", 570 | "version": "3.7.2", 571 | "source": { 572 | "type": "git", 573 | "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", 574 | "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" 575 | }, 576 | "dist": { 577 | "type": "zip", 578 | "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", 579 | "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", 580 | "shasum": "" 581 | }, 582 | "require": { 583 | "ext-simplexml": "*", 584 | "ext-tokenizer": "*", 585 | "ext-xmlwriter": "*", 586 | "php": ">=5.4.0" 587 | }, 588 | "require-dev": { 589 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" 590 | }, 591 | "bin": [ 592 | "bin/phpcs", 593 | "bin/phpcbf" 594 | ], 595 | "type": "library", 596 | "extra": { 597 | "branch-alias": { 598 | "dev-master": "3.x-dev" 599 | } 600 | }, 601 | "notification-url": "https://packagist.org/downloads/", 602 | "license": [ 603 | "BSD-3-Clause" 604 | ], 605 | "authors": [ 606 | { 607 | "name": "Greg Sherwood", 608 | "role": "lead" 609 | } 610 | ], 611 | "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", 612 | "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", 613 | "keywords": [ 614 | "phpcs", 615 | "standards", 616 | "static analysis" 617 | ], 618 | "support": { 619 | "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", 620 | "source": "https://github.com/squizlabs/PHP_CodeSniffer", 621 | "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" 622 | }, 623 | "time": "2023-02-22T23:07:41+00:00" 624 | }, 625 | { 626 | "name": "symfony/finder", 627 | "version": "v6.0.19", 628 | "source": { 629 | "type": "git", 630 | "url": "https://github.com/symfony/finder.git", 631 | "reference": "5cc9cac6586fc0c28cd173780ca696e419fefa11" 632 | }, 633 | "dist": { 634 | "type": "zip", 635 | "url": "https://api.github.com/repos/symfony/finder/zipball/5cc9cac6586fc0c28cd173780ca696e419fefa11", 636 | "reference": "5cc9cac6586fc0c28cd173780ca696e419fefa11", 637 | "shasum": "" 638 | }, 639 | "require": { 640 | "php": ">=8.0.2" 641 | }, 642 | "type": "library", 643 | "autoload": { 644 | "psr-4": { 645 | "Symfony\\Component\\Finder\\": "" 646 | }, 647 | "exclude-from-classmap": [ 648 | "/Tests/" 649 | ] 650 | }, 651 | "notification-url": "https://packagist.org/downloads/", 652 | "license": [ 653 | "MIT" 654 | ], 655 | "authors": [ 656 | { 657 | "name": "Fabien Potencier", 658 | "email": "fabien@symfony.com" 659 | }, 660 | { 661 | "name": "Symfony Community", 662 | "homepage": "https://symfony.com/contributors" 663 | } 664 | ], 665 | "description": "Finds files and directories via an intuitive fluent interface", 666 | "homepage": "https://symfony.com", 667 | "support": { 668 | "source": "https://github.com/symfony/finder/tree/v6.0.19" 669 | }, 670 | "funding": [ 671 | { 672 | "url": "https://symfony.com/sponsor", 673 | "type": "custom" 674 | }, 675 | { 676 | "url": "https://github.com/fabpot", 677 | "type": "github" 678 | }, 679 | { 680 | "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 681 | "type": "tidelift" 682 | } 683 | ], 684 | "time": "2023-01-20T17:44:14+00:00" 685 | }, 686 | { 687 | "name": "wp-cli/i18n-command", 688 | "version": "v2.4.2", 689 | "source": { 690 | "type": "git", 691 | "url": "https://github.com/wp-cli/i18n-command.git", 692 | "reference": "43d5cf8968dbddf90907083ad048f12be5ca3d43" 693 | }, 694 | "dist": { 695 | "type": "zip", 696 | "url": "https://api.github.com/repos/wp-cli/i18n-command/zipball/43d5cf8968dbddf90907083ad048f12be5ca3d43", 697 | "reference": "43d5cf8968dbddf90907083ad048f12be5ca3d43", 698 | "shasum": "" 699 | }, 700 | "require": { 701 | "eftec/bladeone": "3.52", 702 | "gettext/gettext": "^4.8", 703 | "mck89/peast": "^1.13.11", 704 | "wp-cli/wp-cli": "^2.5" 705 | }, 706 | "require-dev": { 707 | "wp-cli/scaffold-command": "^1.2 || ^2", 708 | "wp-cli/wp-cli-tests": "^3.1" 709 | }, 710 | "suggest": { 711 | "ext-json": "Used for reading and generating JSON translation files", 712 | "ext-mbstring": "Used for calculating include/exclude matches in code extraction" 713 | }, 714 | "type": "wp-cli-package", 715 | "extra": { 716 | "branch-alias": { 717 | "dev-main": "2.x-dev" 718 | }, 719 | "bundled": true, 720 | "commands": [ 721 | "i18n", 722 | "i18n make-pot", 723 | "i18n make-json", 724 | "i18n make-mo", 725 | "i18n update-po" 726 | ] 727 | }, 728 | "autoload": { 729 | "files": [ 730 | "i18n-command.php" 731 | ], 732 | "psr-4": { 733 | "WP_CLI\\I18n\\": "src/" 734 | } 735 | }, 736 | "notification-url": "https://packagist.org/downloads/", 737 | "license": [ 738 | "MIT" 739 | ], 740 | "authors": [ 741 | { 742 | "name": "Pascal Birchler", 743 | "homepage": "https://pascalbirchler.com/" 744 | } 745 | ], 746 | "description": "Provides internationalization tools for WordPress projects.", 747 | "homepage": "https://github.com/wp-cli/i18n-command", 748 | "support": { 749 | "issues": "https://github.com/wp-cli/i18n-command/issues", 750 | "source": "https://github.com/wp-cli/i18n-command/tree/v2.4.2" 751 | }, 752 | "time": "2023-02-17T18:14:41+00:00" 753 | }, 754 | { 755 | "name": "wp-cli/mustangostang-spyc", 756 | "version": "0.6.3", 757 | "source": { 758 | "type": "git", 759 | "url": "https://github.com/wp-cli/spyc.git", 760 | "reference": "6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7" 761 | }, 762 | "dist": { 763 | "type": "zip", 764 | "url": "https://api.github.com/repos/wp-cli/spyc/zipball/6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7", 765 | "reference": "6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7", 766 | "shasum": "" 767 | }, 768 | "require": { 769 | "php": ">=5.3.1" 770 | }, 771 | "require-dev": { 772 | "phpunit/phpunit": "4.3.*@dev" 773 | }, 774 | "type": "library", 775 | "extra": { 776 | "branch-alias": { 777 | "dev-master": "0.5.x-dev" 778 | } 779 | }, 780 | "autoload": { 781 | "files": [ 782 | "includes/functions.php" 783 | ], 784 | "psr-4": { 785 | "Mustangostang\\": "src/" 786 | } 787 | }, 788 | "notification-url": "https://packagist.org/downloads/", 789 | "license": [ 790 | "MIT" 791 | ], 792 | "authors": [ 793 | { 794 | "name": "mustangostang", 795 | "email": "vlad.andersen@gmail.com" 796 | } 797 | ], 798 | "description": "A simple YAML loader/dumper class for PHP (WP-CLI fork)", 799 | "homepage": "https://github.com/mustangostang/spyc/", 800 | "support": { 801 | "source": "https://github.com/wp-cli/spyc/tree/autoload" 802 | }, 803 | "time": "2017-04-25T11:26:20+00:00" 804 | }, 805 | { 806 | "name": "wp-cli/php-cli-tools", 807 | "version": "v0.11.18", 808 | "source": { 809 | "type": "git", 810 | "url": "https://github.com/wp-cli/php-cli-tools.git", 811 | "reference": "0f503a790698cb36cf835e5c8d09cd4b64bf2325" 812 | }, 813 | "dist": { 814 | "type": "zip", 815 | "url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/0f503a790698cb36cf835e5c8d09cd4b64bf2325", 816 | "reference": "0f503a790698cb36cf835e5c8d09cd4b64bf2325", 817 | "shasum": "" 818 | }, 819 | "require": { 820 | "php": ">= 5.3.0" 821 | }, 822 | "require-dev": { 823 | "roave/security-advisories": "dev-latest", 824 | "wp-cli/wp-cli-tests": "^3.1.6" 825 | }, 826 | "type": "library", 827 | "extra": { 828 | "branch-alias": { 829 | "dev-master": "0.11.x-dev" 830 | } 831 | }, 832 | "autoload": { 833 | "files": [ 834 | "lib/cli/cli.php" 835 | ], 836 | "psr-0": { 837 | "cli": "lib/" 838 | } 839 | }, 840 | "notification-url": "https://packagist.org/downloads/", 841 | "license": [ 842 | "MIT" 843 | ], 844 | "authors": [ 845 | { 846 | "name": "Daniel Bachhuber", 847 | "email": "daniel@handbuilt.co", 848 | "role": "Maintainer" 849 | }, 850 | { 851 | "name": "James Logsdon", 852 | "email": "jlogsdon@php.net", 853 | "role": "Developer" 854 | } 855 | ], 856 | "description": "Console utilities for PHP", 857 | "homepage": "http://github.com/wp-cli/php-cli-tools", 858 | "keywords": [ 859 | "cli", 860 | "console" 861 | ], 862 | "support": { 863 | "issues": "https://github.com/wp-cli/php-cli-tools/issues", 864 | "source": "https://github.com/wp-cli/php-cli-tools/tree/v0.11.18" 865 | }, 866 | "time": "2023-04-04T16:03:53+00:00" 867 | }, 868 | { 869 | "name": "wp-cli/wp-cli", 870 | "version": "v2.7.1", 871 | "source": { 872 | "type": "git", 873 | "url": "https://github.com/wp-cli/wp-cli.git", 874 | "reference": "1ddc754f1c15e56fb2cdd1a4e82bd0ec6ca32a76" 875 | }, 876 | "dist": { 877 | "type": "zip", 878 | "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/1ddc754f1c15e56fb2cdd1a4e82bd0ec6ca32a76", 879 | "reference": "1ddc754f1c15e56fb2cdd1a4e82bd0ec6ca32a76", 880 | "shasum": "" 881 | }, 882 | "require": { 883 | "ext-curl": "*", 884 | "mustache/mustache": "^2.14.1", 885 | "php": "^5.6 || ^7.0 || ^8.0", 886 | "rmccue/requests": "^1.8", 887 | "symfony/finder": ">2.7", 888 | "wp-cli/mustangostang-spyc": "^0.6.3", 889 | "wp-cli/php-cli-tools": "~0.11.2" 890 | }, 891 | "require-dev": { 892 | "roave/security-advisories": "dev-latest", 893 | "wp-cli/db-command": "^1.3 || ^2", 894 | "wp-cli/entity-command": "^1.2 || ^2", 895 | "wp-cli/extension-command": "^1.1 || ^2", 896 | "wp-cli/package-command": "^1 || ^2", 897 | "wp-cli/wp-cli-tests": "^3.1.6" 898 | }, 899 | "suggest": { 900 | "ext-readline": "Include for a better --prompt implementation", 901 | "ext-zip": "Needed to support extraction of ZIP archives when doing downloads or updates" 902 | }, 903 | "bin": [ 904 | "bin/wp", 905 | "bin/wp.bat" 906 | ], 907 | "type": "library", 908 | "extra": { 909 | "branch-alias": { 910 | "dev-master": "2.8.x-dev" 911 | } 912 | }, 913 | "autoload": { 914 | "psr-0": { 915 | "WP_CLI\\": "php/" 916 | }, 917 | "classmap": [ 918 | "php/class-wp-cli.php", 919 | "php/class-wp-cli-command.php" 920 | ] 921 | }, 922 | "notification-url": "https://packagist.org/downloads/", 923 | "license": [ 924 | "MIT" 925 | ], 926 | "description": "WP-CLI framework", 927 | "homepage": "https://wp-cli.org", 928 | "keywords": [ 929 | "cli", 930 | "wordpress" 931 | ], 932 | "support": { 933 | "docs": "https://make.wordpress.org/cli/handbook/", 934 | "issues": "https://github.com/wp-cli/wp-cli/issues", 935 | "source": "https://github.com/wp-cli/wp-cli" 936 | }, 937 | "time": "2022-10-17T23:10:42+00:00" 938 | }, 939 | { 940 | "name": "wp-coding-standards/wpcs", 941 | "version": "2.3.0", 942 | "source": { 943 | "type": "git", 944 | "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", 945 | "reference": "7da1894633f168fe244afc6de00d141f27517b62" 946 | }, 947 | "dist": { 948 | "type": "zip", 949 | "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7da1894633f168fe244afc6de00d141f27517b62", 950 | "reference": "7da1894633f168fe244afc6de00d141f27517b62", 951 | "shasum": "" 952 | }, 953 | "require": { 954 | "php": ">=5.4", 955 | "squizlabs/php_codesniffer": "^3.3.1" 956 | }, 957 | "require-dev": { 958 | "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6", 959 | "phpcompatibility/php-compatibility": "^9.0", 960 | "phpcsstandards/phpcsdevtools": "^1.0", 961 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" 962 | }, 963 | "suggest": { 964 | "dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically." 965 | }, 966 | "type": "phpcodesniffer-standard", 967 | "notification-url": "https://packagist.org/downloads/", 968 | "license": [ 969 | "MIT" 970 | ], 971 | "authors": [ 972 | { 973 | "name": "Contributors", 974 | "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" 975 | } 976 | ], 977 | "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", 978 | "keywords": [ 979 | "phpcs", 980 | "standards", 981 | "wordpress" 982 | ], 983 | "support": { 984 | "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", 985 | "source": "https://github.com/WordPress/WordPress-Coding-Standards", 986 | "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" 987 | }, 988 | "time": "2020-05-13T23:57:56+00:00" 989 | } 990 | ], 991 | "aliases": [], 992 | "minimum-stability": "stable", 993 | "stability-flags": [], 994 | "prefer-stable": false, 995 | "prefer-lowest": false, 996 | "platform": [], 997 | "platform-dev": [], 998 | "plugin-api-version": "2.3.0" 999 | } 1000 | -------------------------------------------------------------------------------- /includes/class-gamajo-dashboard-glancer.php: -------------------------------------------------------------------------------- 1 | unset_invalid_post_types( (array) $post_types ); 59 | 60 | // If all given post types were invalid, bail now 61 | if ( ! $post_types ) { 62 | return; 63 | } 64 | 65 | // Register each combination of given post type and status 66 | foreach ( $post_types as $post_type ) { 67 | foreach ( (array) $statuses as $status ) { 68 | $this->items[] = array( 69 | 'type' => $post_type, 70 | 'status' => $status, // No checks yet to see if status is valid 71 | ); 72 | } 73 | } 74 | } 75 | 76 | /** 77 | * Show the items on the dashboard widget. 78 | * 79 | * @since 1.0.0 80 | * 81 | * @param array $items Existing "At a Glance" items. 82 | * 83 | * @return array Filtered "At a Glance" items. 84 | */ 85 | public function show( $items ) { 86 | foreach ( $this->items as $item ) { 87 | $item_markup = $this->get_single_item( $item ); 88 | if ( $item_markup ) { 89 | $items[] = $item_markup; 90 | } 91 | } 92 | // Reset items, so items aren't shown again if show() is re-called 93 | unset( $this->items ); 94 | 95 | return $items; 96 | } 97 | 98 | /** 99 | * Check one or more post types to see if they are valid. 100 | * 101 | * @since 1.0.0 102 | * 103 | * @param array $post_types Each of the post types to check. 104 | * 105 | * @return array List of the given post types that are valid. 106 | */ 107 | protected function unset_invalid_post_types( array $post_types ) { 108 | foreach ( $post_types as $index => $post_type ) { 109 | $post_type_object = get_post_type_object( $post_type ); 110 | if ( is_null( $post_type_object ) ) { 111 | unset( $post_types[ $index ] ); 112 | } 113 | } 114 | 115 | return $post_types; 116 | } 117 | 118 | /** 119 | * Build and return the data and markup for a single item. 120 | * 121 | * If the item count is zero, return an empty string, to avoid visual clutter. 122 | * 123 | * @since 1.0.0 124 | * 125 | * @param array $item Registered item. 126 | * 127 | * @return string Markup, or empty string if item count is zero. 128 | */ 129 | protected function get_single_item( array $item ) { 130 | $num_posts = wp_count_posts( $item['type'] ); 131 | $count = (int) $num_posts->{$item['status']}; 132 | 133 | if ( ! $count ) { 134 | return ''; 135 | } 136 | 137 | $href = $this->get_link_url( $item ); 138 | $text = number_format_i18n( $count ) . ' ' . $this->get_label( $item, $count ); 139 | $class = $item['type'] . '-count'; 140 | return $this->maybe_link( $text, $href, $class ); 141 | } 142 | 143 | /** 144 | * Get the singular or plural label for an item. 145 | * 146 | * @since 1.0.0 147 | * 148 | * @param array $item Registered item. 149 | * @param int $count Number of items present in WP. 150 | * 151 | * @return string 152 | */ 153 | protected function get_label( array $item, $count ) { 154 | 155 | $post_type_object = get_post_type_object( $item['type'] ); 156 | if ( 1 === $count ) { 157 | $label = $post_type_object->labels->singular_name; 158 | } else { 159 | $label = $post_type_object->labels->name; 160 | } 161 | 162 | // Append status for non-publish statuses for disambiguation 163 | if ( 'publish' !== $item['status'] ) { 164 | $label .= ' (' . $item['status'] . ')'; 165 | } 166 | 167 | return $label; 168 | } 169 | 170 | /** 171 | * Build the URL that linked items use. 172 | * 173 | * @since 1.0.0 174 | * 175 | * @param array $item Registered item. 176 | * 177 | * @return string Admin URL to view the entries of the given post type with the given status 178 | */ 179 | public function get_link_url( array $item ) { 180 | return 'edit.php?post_status=' . $item['status'] . '&post_type=' . $item['type']; 181 | } 182 | 183 | /** 184 | * Wrap a glance item in a link, if the current user can edit posts. 185 | * 186 | * @since 1.0.0 187 | * 188 | * @param string $text Text to potentially wrap in a link. 189 | * @param string $href Link target. 190 | * 191 | * @return string Text wrapped in a link if current user can edit posts, or original text otherwise. 192 | */ 193 | protected function maybe_link( $text, $href, $class ) { 194 | if ( current_user_can( 'edit_posts' ) ) { 195 | return '' . esc_html( $text ) . ''; 196 | } else { 197 | return '' . esc_html( $text ) . ''; 198 | } 199 | } 200 | } 201 | -------------------------------------------------------------------------------- /includes/class-gamajo-post-type.php: -------------------------------------------------------------------------------- 1 | args ) { 45 | $this->set_args(); 46 | } 47 | register_post_type( $this->post_type, $this->args ); 48 | } 49 | 50 | /** 51 | * Unregister the post type. 52 | * 53 | * Since there is no unregister_post_type() function, the value is unset from the global instead. 54 | * 55 | * @since 1.0.0 56 | * 57 | * @global array $wp_post_types 58 | */ 59 | public function unregister() { 60 | global $wp_post_types; 61 | if ( isset( $wp_post_types[ $this->post_type ] ) ) { 62 | unset( $wp_post_types[ $this->post_type ] ); 63 | } 64 | } 65 | 66 | /** 67 | * Merge any provided arguments with the default ones for a post type. 68 | * 69 | * @since 1.0.0 70 | * 71 | * @param array $args Post type arguments. 72 | */ 73 | public function set_args( $args = null ) { 74 | $this->args = wp_parse_args( $args, $this->default_args() ); 75 | } 76 | 77 | /** 78 | * Return post type arguments. 79 | * 80 | * @since 1.0.0 81 | * 82 | * @return array Post type arguments. 83 | */ 84 | public function get_args() { 85 | return $this->args; 86 | } 87 | 88 | /** 89 | * Return post type ID. 90 | * 91 | * @since 1.0.0 92 | * 93 | * @return string Post type ID. 94 | */ 95 | public function get_post_type() { 96 | return $this->post_type; 97 | } 98 | 99 | /** 100 | * Return post type updated messages. 101 | * 102 | * @since 1.0.0 103 | * 104 | * @return array Post type updated messages. 105 | */ 106 | abstract public function messages(); 107 | 108 | /** 109 | * Return post type default arguments. 110 | * 111 | * @since 1.0.0 112 | * 113 | * @return array Post type default arguments. 114 | */ 115 | abstract protected function default_args(); 116 | } 117 | -------------------------------------------------------------------------------- /includes/class-gamajo-single-entry-term-body-classes.php: -------------------------------------------------------------------------------- 1 | post_type = $post_type; 38 | 39 | // Add taxonomy terms as body classes 40 | add_filter( 'body_class', array( $this, 'body_class' ) ); 41 | } 42 | 43 | /** 44 | * Add taxonomy terms as body classes. 45 | * 46 | * If the taxonomy doesn't exist (has been unregistered), then get_the_terms() returns WP_Error, which is checked 47 | * for before adding classes. 48 | * 49 | * @since 1.0.0 50 | * 51 | * @param array $classes Existing body classes. 52 | * 53 | * @return array Amended body classes. 54 | */ 55 | public function body_class( $classes ) { 56 | // Only single entries of a certain post type should have the taxonomy body classes 57 | if ( ! is_singular( $this->post_type ) ) { 58 | return $classes; 59 | } 60 | 61 | global $portfolio_post_type_registrations; 62 | return array_merge( $classes, $this->get_taxonomy_term_classes( $portfolio_post_type_registrations->taxonomies ) ); 63 | } 64 | 65 | /** 66 | * Get classes for taxonomy terms. 67 | * 68 | * @since 1.0.0 69 | * 70 | * @param array|string $taxonomies Taxonomy slugs. Single slug only if string. 71 | * 72 | * @return array Classes in form of {taxonomy-slug}-{term-slug}. 73 | */ 74 | protected function get_taxonomy_term_classes( $taxonomies ) { 75 | $classes = array(); 76 | foreach ( (array) $taxonomies as $taxonomy ) { 77 | foreach ( $this->get_terms( $taxonomy ) as $term ) { 78 | $classes[] = $this->get_taxonomy_term_class( $taxonomy, $term->slug ); 79 | } 80 | } 81 | 82 | return $classes; 83 | } 84 | 85 | /** 86 | * Get all the terms for a taxonomy applied to a post. 87 | * 88 | * If taxonomy is not registered, return an empty array. 89 | * 90 | * @since 1.0.0 91 | * 92 | * @param array|string $taxonomy Taxonomy slugs. 93 | * @param int $post_id Optional. Post ID. Defaults to current global post ID. 94 | * 95 | * @return array Terms, or empty array if taxonomy not found. 96 | */ 97 | protected function get_terms( $taxonomy, $post_id = null ) { 98 | if ( is_null( $post_id ) ) { 99 | $post_id = get_the_ID(); 100 | } 101 | 102 | $terms = get_the_terms( $post_id, $taxonomy ); 103 | 104 | if ( is_wp_error( $terms ) || ! $terms ) { 105 | $terms = array(); 106 | } 107 | 108 | return $terms; 109 | } 110 | 111 | /** 112 | * Get string made up of taxonomy and term slugs, sanitized to be a HTML class. 113 | * 114 | * @since 1.0.0 115 | * 116 | * @param string $taxonomy_slug Taxonomy slug. 117 | * @param string $term_slug Term slug. 118 | * 119 | * @return string Sanitized class in the form of {$taxonomy_slug}-{$term_slug}. 120 | */ 121 | protected function get_taxonomy_term_class( $taxonomy_slug, $term_slug ) { 122 | return sanitize_html_class( str_replace( '_', '-', $taxonomy_slug ) . '-' . $term_slug ); 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /includes/class-gamajo-taxonomy.php: -------------------------------------------------------------------------------- 1 | args ) { 52 | $this->set_args(); 53 | } 54 | register_taxonomy( $this->taxonomy, $object_type, $this->args ); 55 | } 56 | 57 | /** 58 | * Unregister the post type. 59 | * 60 | * Since there is no unregister_taxonomy() function, the value is unset from the global instead. 61 | * 62 | * @since 1.0.0 63 | * 64 | * @global array $wp_taxonomies 65 | */ 66 | public function unregister() { 67 | global $wp_taxonomies; 68 | if ( taxonomy_exists( $this->taxonomy ) ) { 69 | unset( $wp_taxonomies[ $this->taxonomy ] ); 70 | } 71 | // Alternatively, to leave it not registered to any post type: 72 | // register_taxonomy( $this->taxonomy, null ); 73 | } 74 | 75 | /** 76 | * Merge any provided arguments with the default ones for the taxonomy. 77 | * 78 | * @since 1.0.0 79 | * 80 | * @param array $args Taxonomy arguments. 81 | */ 82 | public function set_args( $args = null ) { 83 | $this->args = wp_parse_args( $args, $this->default_args() ); 84 | } 85 | 86 | /** 87 | * Return taxonomy arguments. 88 | * 89 | * @since 1.0.0 90 | * 91 | * @return array Post type arguments. 92 | */ 93 | public function get_args() { 94 | return $this->args; 95 | } 96 | 97 | /** 98 | * Return taxonomy ID. 99 | * 100 | * @since 1.0.0 101 | * 102 | * @return string Taxonomy ID. 103 | */ 104 | public function get_taxonomy() { 105 | return $this->taxonomy; 106 | } 107 | 108 | /** 109 | * Return taxonomy default arguments. 110 | * 111 | * @since 1.0.0 112 | * 113 | * @return array Taxonomy default arguments. 114 | */ 115 | abstract protected function default_args(); 116 | } 117 | -------------------------------------------------------------------------------- /includes/class-portfolio-post-type-admin.php: -------------------------------------------------------------------------------- 1 | registration_handler = $registration_handler; 26 | } 27 | 28 | public function init() { 29 | 30 | // Add thumbnail support for this post type 31 | $supported = get_theme_support( 'post-thumbnails' ); 32 | if ( $supported !== true ) { 33 | 34 | if ( is_array( $supported ) ) { 35 | array_push( $supported, $this->registration_handler->post_type ); 36 | } else { 37 | $supported = array( $this->registration_handler->post_type ); 38 | } 39 | 40 | add_theme_support( 'post-thumbnails', $supported ); 41 | } 42 | 43 | // Add thumbnails to column view 44 | add_filter( 'manage_edit-' . $this->registration_handler->post_type . '_columns', array( $this, 'add_thumbnail_column' ), 10, 1 ); 45 | add_action( 'manage_posts_custom_column', array( $this, 'display_thumbnail' ), 10, 1 ); 46 | 47 | // Allow filtering of posts by taxonomy in the admin view 48 | add_action( 'restrict_manage_posts', array( $this, 'add_taxonomy_filters' ) ); 49 | 50 | // Show post counts in the dashboard 51 | add_filter( 'dashboard_glance_items', array( $this, 'add_glance_counts' ), 10, 1 ); 52 | 53 | // Adds portfolio icon to the dashboard "At a Glance" 54 | add_action( 'admin_head', array( $this, 'add_glance_icon' ) ); 55 | } 56 | 57 | /** 58 | * Add columns to post type list screen. 59 | * 60 | * @link http://wptheming.com/2010/07/column-edit-pages/ 61 | * 62 | * @param array $columns Existing columns. 63 | * 64 | * @return array Amended columns. 65 | */ 66 | public function add_thumbnail_column( $columns ) { 67 | $column_thumbnail = array( 'thumbnail' => __( 'Thumbnail', 'portfolio-post-type' ) ); 68 | return array_slice( $columns, 0, 2, true ) + $column_thumbnail + array_slice( $columns, 1, null, true ); 69 | } 70 | 71 | /** 72 | * Custom column callback 73 | * 74 | * @global stdClass $post Post object. 75 | * 76 | * @param string $column Column ID. 77 | */ 78 | public function display_thumbnail( $column ) { 79 | switch ( $column ) { 80 | case 'thumbnail': 81 | echo get_the_post_thumbnail( get_the_ID(), array( 35, 35 ) ); 82 | break; 83 | } 84 | } 85 | 86 | /** 87 | * Add taxonomy filters to the post type list page. 88 | * 89 | * Code artfully lifted from http://pippinsplugins.com/ 90 | * 91 | * @global string $typenow 92 | */ 93 | public function add_taxonomy_filters() { 94 | global $typenow; 95 | 96 | // Must set this to the post type you want the filter(s) displayed on 97 | if ( $this->registration_handler->post_type !== $typenow ) { 98 | return; 99 | } 100 | 101 | foreach ( $this->registration_handler->taxonomies as $tax_slug ) { 102 | echo $this->build_taxonomy_filter( $tax_slug ); 103 | } 104 | } 105 | 106 | /** 107 | * Build an individual dropdown filter. 108 | * 109 | * @param string $tax_slug Taxonomy slug to build filter for. 110 | * 111 | * @return string Markup, or empty string if taxonomy has no terms. 112 | */ 113 | protected function build_taxonomy_filter( $tax_slug ) { 114 | $terms = get_terms( $tax_slug ); 115 | if ( 0 == count( $terms ) ) { 116 | return ''; 117 | } 118 | 119 | $tax_name = $this->get_taxonomy_name_from_slug( $tax_slug ); 120 | $current_tax_slug = isset( $_GET[ $tax_slug ] ) ? $_GET[ $tax_slug ] : false; 121 | 122 | $filter = ''; 126 | 127 | return $filter; 128 | } 129 | 130 | /** 131 | * Get the friendly taxonomy name, if given a taxonomy slug. 132 | * 133 | * @param string $tax_slug Taxonomy slug. 134 | * 135 | * @return string Friendly name of taxonomy, or empty string if not a valid taxonomy. 136 | */ 137 | protected function get_taxonomy_name_from_slug( $tax_slug ) { 138 | $tax_obj = get_taxonomy( $tax_slug ); 139 | if ( ! $tax_obj ) { 140 | return ''; 141 | } 142 | return $tax_obj->labels->name; 143 | } 144 | 145 | /** 146 | * Build a series of option elements from an array. 147 | * 148 | * Also checks to see if one of the options is selected. 149 | * 150 | * @param array $terms Array of term objects. 151 | * @param string $current_tax_slug Slug of currently selected term. 152 | * 153 | * @return string Markup. 154 | */ 155 | protected function build_term_options( $terms, $current_tax_slug ) { 156 | $options = ''; 157 | foreach ( $terms as $term ) { 158 | $options .= sprintf( 159 | '', 160 | esc_attr( $term->slug ), 161 | selected( $current_tax_slug, $term->slug, false ), 162 | esc_html( $term->name . ' (' . $term->count . ')' ) 163 | ); 164 | } 165 | return $options; 166 | } 167 | 168 | /** 169 | * Add counts to "At a Glance" dashboard widget in WP 3.8+ 170 | * 171 | * @since Unknown 172 | */ 173 | public function add_glance_counts( $items ) { 174 | $glancer = new Gamajo_Dashboard_Glancer(); 175 | $glancer->add( $this->registration_handler->post_type, array( 'publish', 'pending' ) ); 176 | 177 | return $items; 178 | } 179 | 180 | /** 181 | * Displays the portfolio icon in the glance view in the dashboard. 182 | */ 183 | public function add_glance_icon() { 184 | // Styling only needed on dashboard page. 185 | $screen = get_current_screen(); 186 | if ( ! is_object( $screen ) || $screen->id !== 'dashboard' ) { 187 | return; 188 | } 189 | ?> 190 | 195 | __( 'Portfolio', 'portfolio-post-type' ), 40 | 'singular_name' => __( 'Portfolio Item', 'portfolio-post-type' ), 41 | 'menu_name' => _x( 'Portfolio', 'admin menu', 'portfolio-post-type' ), 42 | 'name_admin_bar' => _x( 'Portfolio Item', 'add new on admin bar', 'portfolio-post-type' ), 43 | 'add_new' => __( 'Add New Item', 'portfolio-post-type' ), 44 | 'add_new_item' => __( 'Add New Portfolio Item', 'portfolio-post-type' ), 45 | 'new_item' => __( 'Add New Portfolio Item', 'portfolio-post-type' ), 46 | 'edit_item' => __( 'Edit Portfolio Item', 'portfolio-post-type' ), 47 | 'view_item' => __( 'View Item', 'portfolio-post-type' ), 48 | 'all_items' => __( 'All Portfolio Items', 'portfolio-post-type' ), 49 | 'search_items' => __( 'Search Portfolio', 'portfolio-post-type' ), 50 | 'parent_item_colon' => __( 'Parent Portfolio Item:', 'portfolio-post-type' ), 51 | 'not_found' => __( 'No portfolio items found', 'portfolio-post-type' ), 52 | 'not_found_in_trash' => __( 'No portfolio items found in trash', 'portfolio-post-type' ), 53 | 'filter_items_list' => __( 'Filter portfolio items list', 'portfolio-post-type' ), 54 | 'items_list_navigation' => __( 'Portfolio items list navigation', 'portfolio-post-type' ), 55 | 'items_list' => __( 'Portfolio items list', 'portfolio-post-type' ), 56 | ); 57 | 58 | $supports = array( 59 | 'title', 60 | 'editor', 61 | 'excerpt', 62 | 'thumbnail', 63 | 'comments', 64 | 'author', 65 | 'custom-fields', 66 | 'revisions', 67 | ); 68 | 69 | $args = array( 70 | 'labels' => $labels, 71 | 'supports' => $supports, 72 | 'public' => true, 73 | 'capability_type' => 'post', 74 | 'rewrite' => array( 'slug' => 'portfolio', ), // Permalinks format 75 | 'menu_position' => 5, 76 | 'menu_icon' => 'dashicons-portfolio', 77 | 'has_archive' => true, 78 | 'show_in_rest' => true, 79 | 'show_in_graphql' => true, 80 | 'graphql_single_name' => 'portfolio_item', 81 | 'graphql_plural_name' => 'portfolio_items', 82 | ); 83 | 84 | return apply_filters( 'portfolioposttype_args', $args ); 85 | } 86 | 87 | /** 88 | * Return post type updated messages. 89 | * 90 | * @since 1.0.0 91 | * 92 | * @return array Post type updated messages. 93 | */ 94 | public function messages() { 95 | $post = get_post(); 96 | $post_type = get_post_type( $post ); 97 | $post_type_object = get_post_type_object( $post_type ); 98 | 99 | $messages = array( 100 | 0 => '', // Unused. Messages start at index 1. 101 | 1 => __( 'Portfolio item updated.', 'portfolio-post-type' ), 102 | 2 => __( 'Custom field updated.', 'portfolio-post-type' ), 103 | 3 => __( 'Custom field deleted.', 'portfolio-post-type' ), 104 | 4 => __( 'Portfolio item updated.', 'portfolio-post-type' ), 105 | /* translators: %s: date and time of the revision */ 106 | 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Portfolio item restored to revision from %s', 'portfolio-post-type' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, 107 | 6 => __( 'Portfolio item published.', 'portfolio-post-type' ), 108 | 7 => __( 'Portfolio item saved.', 'portfolio-post-type' ), 109 | 8 => __( 'Portfolio item submitted.', 'portfolio-post-type' ), 110 | 9 => sprintf( 111 | __( 'Portfolio item scheduled for: %1$s.', 'portfolio-post-type' ), 112 | /* translators: Publish box date format, see http://php.net/date */ 113 | date_i18n( __( 'M j, Y @ G:i', 'portfolio-post-type' ), strtotime( $post->post_date ) ) 114 | ), 115 | 10 => __( 'Portfolio item draft updated.', 'portfolio-post-type' ), 116 | ); 117 | 118 | if ( $post_type_object->publicly_queryable ) { 119 | $permalink = get_permalink( $post->ID ); 120 | $preview_permalink = add_query_arg( 'preview', 'true', $permalink ); 121 | 122 | $view_link = sprintf( ' %s', esc_url( $permalink ), __( 'View portfolio item', 'portfolio-post-type' ) ); 123 | $preview_link = sprintf( ' %s', esc_url( $preview_permalink ), __( 'Preview portfolio item', 'portfolio-post-type' ) ); 124 | 125 | $messages[1] .= $view_link; 126 | $messages[6] .= $view_link; 127 | $messages[9] .= $view_link; 128 | $messages[8] .= $preview_link; 129 | $messages[10] .= $preview_link; 130 | } 131 | 132 | return $messages; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /includes/class-portfolio-post-type-registrations.php: -------------------------------------------------------------------------------- 1 | register(); 39 | $this->post_type = $portfolio_post_type_post_type->get_post_type(); 40 | 41 | $portfolio_post_type_taxonomy_category = new Portfolio_Post_Type_Taxonomy_Category(); 42 | $portfolio_post_type_taxonomy_category->register(); 43 | $this->taxonomies[] = $portfolio_post_type_taxonomy_category->get_taxonomy(); 44 | register_taxonomy_for_object_type( 45 | $portfolio_post_type_taxonomy_category->get_taxonomy(), 46 | $portfolio_post_type_post_type->get_post_type() 47 | ); 48 | 49 | $portfolio_post_type_taxonomy_tag = new Portfolio_Post_Type_Taxonomy_Tag(); 50 | $portfolio_post_type_taxonomy_tag->register(); 51 | $this->taxonomies[] = $portfolio_post_type_taxonomy_tag->get_taxonomy(); 52 | register_taxonomy_for_object_type( 53 | $portfolio_post_type_taxonomy_tag->get_taxonomy(), 54 | $portfolio_post_type_post_type->get_post_type() 55 | ); 56 | } 57 | 58 | /** 59 | * Unregister post type and taxonomies registrations. 60 | */ 61 | public function unregister() { 62 | global $portfolio_post_type_post_type, $portfolio_post_type_taxonomy_category, $portfolio_post_type_taxonomy_tag; 63 | $portfolio_post_type_post_type->unregister(); 64 | $this->post_type = null; 65 | 66 | $portfolio_post_type_taxonomy_category->unregister(); 67 | unset( $this->taxonomies[ $portfolio_post_type_taxonomy_category->get_taxonomy() ] ); 68 | 69 | $portfolio_post_type_taxonomy_tag->unregister(); 70 | unset( $this->taxonomies[ $portfolio_post_type_taxonomy_tag->get_taxonomy() ] ); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /includes/class-portfolio-post-type-taxonomy-category.php: -------------------------------------------------------------------------------- 1 | __( 'Portfolio Categories', 'portfolio-post-type' ), 40 | 'singular_name' => __( 'Portfolio Category', 'portfolio-post-type' ), 41 | 'menu_name' => __( 'Portfolio Categories', 'portfolio-post-type' ), 42 | 'edit_item' => __( 'Edit Portfolio Category', 'portfolio-post-type' ), 43 | 'update_item' => __( 'Update Portfolio Category', 'portfolio-post-type' ), 44 | 'add_new_item' => __( 'Add New Portfolio Category', 'portfolio-post-type' ), 45 | 'new_item_name' => __( 'New Portfolio Category Name', 'portfolio-post-type' ), 46 | 'parent_item' => __( 'Parent Portfolio Category', 'portfolio-post-type' ), 47 | 'parent_item_colon' => __( 'Parent Portfolio Category:', 'portfolio-post-type' ), 48 | 'all_items' => __( 'All Portfolio Categories', 'portfolio-post-type' ), 49 | 'search_items' => __( 'Search Portfolio Categories', 'portfolio-post-type' ), 50 | 'popular_items' => __( 'Popular Portfolio Categories', 'portfolio-post-type' ), 51 | 'separate_items_with_commas' => __( 'Separate portfolio categories with commas', 'portfolio-post-type' ), 52 | 'add_or_remove_items' => __( 'Add or remove portfolio categories', 'portfolio-post-type' ), 53 | 'choose_from_most_used' => __( 'Choose from the most used portfolio categories', 'portfolio-post-type' ), 54 | 'not_found' => __( 'No portfolio categories found.', 'portfolio-post-type' ), 55 | 'items_list_navigation' => __( 'Portfolio categories list navigation', 'portfolio-post-type' ), 56 | 'items_list' => __( 'Portfolio categories list', 'portfolio-post-type' ), 57 | ); 58 | 59 | $args = array( 60 | 'labels' => $labels, 61 | 'public' => true, 62 | 'show_in_nav_menus' => true, 63 | 'show_ui' => true, 64 | 'show_tagcloud' => true, 65 | 'hierarchical' => true, 66 | 'rewrite' => array( 'slug' => 'portfolio_category' ), 67 | 'show_admin_column' => true, 68 | 'query_var' => true, 69 | 'show_in_rest' => true, 70 | 'show_in_graphql' => true, 71 | 'graphql_single_name' => 'portfolio_category', 72 | 'graphql_plural_name' => 'portfolio_categories', 73 | 74 | ); 75 | 76 | return apply_filters( 'portfolioposttype_category_args', $args ); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /includes/class-portfolio-post-type-taxonomy-tag.php: -------------------------------------------------------------------------------- 1 | __( 'Portfolio Tags', 'portfolio-post-type' ), 40 | 'singular_name' => __( 'Portfolio Tag', 'portfolio-post-type' ), 41 | 'menu_name' => __( 'Portfolio Tags', 'portfolio-post-type' ), 42 | 'edit_item' => __( 'Edit Portfolio Tag', 'portfolio-post-type' ), 43 | 'update_item' => __( 'Update Portfolio Tag', 'portfolio-post-type' ), 44 | 'add_new_item' => __( 'Add New Portfolio Tag', 'portfolio-post-type' ), 45 | 'new_item_name' => __( 'New Portfolio Tag Name', 'portfolio-post-type' ), 46 | 'parent_item' => __( 'Parent Portfolio Tag', 'portfolio-post-type' ), 47 | 'parent_item_colon' => __( 'Parent Portfolio Tag:', 'portfolio-post-type' ), 48 | 'all_items' => __( 'All Portfolio Tags', 'portfolio-post-type' ), 49 | 'search_items' => __( 'Search Portfolio Tags', 'portfolio-post-type' ), 50 | 'popular_items' => __( 'Popular Portfolio Tags', 'portfolio-post-type' ), 51 | 'separate_items_with_commas' => __( 'Separate portfolio tags with commas', 'portfolio-post-type' ), 52 | 'add_or_remove_items' => __( 'Add or remove portfolio tags', 'portfolio-post-type' ), 53 | 'choose_from_most_used' => __( 'Choose from the most used portfolio tags', 'portfolio-post-type' ), 54 | 'not_found' => __( 'No portfolio tags found.', 'portfolio-post-type' ), 55 | 'items_list_navigation' => __( 'Portfolio tags list navigation', 'portfolio-post-type' ), 56 | 'items_list' => __( 'Portfolio tags list', 'portfolio-post-type' ), 57 | ); 58 | 59 | $args = array( 60 | 'labels' => $labels, 61 | 'public' => true, 62 | 'show_in_nav_menus' => true, 63 | 'show_ui' => true, 64 | 'show_tagcloud' => true, 65 | 'hierarchical' => false, 66 | 'rewrite' => array( 'slug' => 'portfolio_tag' ), 67 | 'show_admin_column' => true, 68 | 'query_var' => true, 69 | 'show_in_rest' => true, 70 | ); 71 | 72 | return apply_filters( 'portfolioposttype_tag_args', $args ); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /includes/class-portfolio-post-type.php: -------------------------------------------------------------------------------- 1 | registration_handler = $registration_handler; 50 | 51 | // Load plugin text domain 52 | add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); 53 | 54 | // Activate plugin when new blog is added 55 | add_action( 'wpmu_new_blog', array( $this, 'activate_new_site' ) ); 56 | } 57 | 58 | /** 59 | * Fired when the plugin is activated. 60 | * 61 | * @since 0.7.0 62 | * 63 | * @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is 64 | * disabled or plugin is activated on an individual blog. 65 | */ 66 | public function activate( $network_wide ) { 67 | if ( function_exists( 'is_multisite' ) && is_multisite() ) { 68 | if ( $network_wide && $blog_ids = $this->get_blog_ids() ) { 69 | foreach ( $blog_ids as $blog_id ) { 70 | switch_to_blog( $blog_id ); 71 | $this->single_activate(); 72 | } 73 | restore_current_blog(); 74 | } else { 75 | $this->single_activate(); 76 | } 77 | } else { 78 | $this->single_activate(); 79 | } 80 | } 81 | 82 | /** 83 | * Fired when the plugin is deactivated. 84 | * 85 | * @since 0.7.0 86 | * 87 | * @param boolean $network_wide True if WPMU superadmin uses "Network Deactivate" action, false if WPMU is 88 | * disabled or plugin is deactivated on an individual blog. 89 | */ 90 | public function deactivate( $network_wide ) { 91 | if ( function_exists( 'is_multisite' ) && is_multisite() ) { 92 | if ( $network_wide && $blog_ids = $this->get_blog_ids() ) { 93 | foreach ( $blog_ids as $blog_id ) { 94 | switch_to_blog( $blog_id ); 95 | $this->single_deactivate(); 96 | } 97 | restore_current_blog(); 98 | } else { 99 | $this->single_deactivate(); 100 | } 101 | } else { 102 | $this->single_deactivate(); 103 | } 104 | } 105 | 106 | /** 107 | * Fired when a new site is activated with a WPMU environment. 108 | * 109 | * @since 0.7.0 110 | * 111 | * @param int $blog_id ID of the new blog. 112 | */ 113 | public function activate_new_site( $blog_id ) { 114 | if ( 1 !== did_action( 'wpmu_new_blog' ) ) { 115 | return; 116 | } 117 | 118 | switch_to_blog( $blog_id ); 119 | $this->single_activate(); 120 | restore_current_blog(); 121 | } 122 | 123 | /** 124 | * Get all blog ids of blogs in the current network that are: 125 | * - not archived 126 | * - not spam 127 | * - not deleted 128 | * 129 | * @since 0.7.0 130 | * 131 | * @return array|false The blog ids, false if no matches. 132 | */ 133 | private function get_blog_ids() { 134 | global $wpdb; 135 | 136 | // get an array of blog ids 137 | $sql = "SELECT blog_id FROM $wpdb->blogs 138 | WHERE archived = '0' AND spam = '0' 139 | AND deleted = '0'"; 140 | return $wpdb->get_col( $sql ); 141 | } 142 | 143 | /** 144 | * Fired for each blog when the plugin is activated. 145 | * 146 | * @since 0.7.0 147 | */ 148 | private function single_activate() { 149 | $this->registration_handler->register(); 150 | flush_rewrite_rules(); 151 | } 152 | 153 | /** 154 | * Fired for each blog when the plugin is deactivated. 155 | * 156 | * @since 0.7.0 157 | */ 158 | private function single_deactivate() { 159 | flush_rewrite_rules(); 160 | } 161 | 162 | /** 163 | * Load the plugin text domain for translation. 164 | * 165 | * @since 0.7.0 166 | */ 167 | public function load_plugin_textdomain() { 168 | $domain = self::PLUGIN_SLUG; 169 | $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); 170 | 171 | load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' ); 172 | load_plugin_textdomain( $domain, false, basename( plugin_dir_path( dirname( __FILE__ ) ) ) . '/languages' ); 173 | } 174 | 175 | } 176 | -------------------------------------------------------------------------------- /includes/interface-gamajo-registerable.php: -------------------------------------------------------------------------------- 1 | \n" 11 | "Language-Team: Pedro Mendonça \n" 12 | "Language: pt_PT\n" 13 | "MIME-Version: 1.0\n" 14 | "Content-Type: text/plain; charset=UTF-8\n" 15 | "Content-Transfer-Encoding: 8bit\n" 16 | "X-Generator: Poedit 1.8.6\n" 17 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 18 | "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;" 19 | "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;" 20 | "esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;" 21 | "esc_html_x:1,2c\n" 22 | "X-Poedit-Basepath: ..\n" 23 | "X-Poedit-SearchPath-0: .\n" 24 | 25 | #: includes/class-gamajo-dashboard-glancer.php:54 26 | msgid "" 27 | "Trying to add At a Glance items to dashboard widget afterhook already fired" 28 | msgstr "Tentar adicionar itens do At a Glance ao widget do painel" 29 | 30 | #: includes/class-portfolio-post-type-admin.php:68 31 | msgid "Thumbnail" 32 | msgstr "Miniatura" 33 | 34 | #: includes/class-portfolio-post-type-post-type.php:39 35 | msgid "Portfolio" 36 | msgstr "Portfólio" 37 | 38 | #: includes/class-portfolio-post-type-post-type.php:40 39 | msgid "Portfolio Item" 40 | msgstr "Item de Portfólio" 41 | 42 | #: includes/class-portfolio-post-type-post-type.php:41 43 | msgctxt "admin menu" 44 | msgid "Portfolio" 45 | msgstr "Portfólio" 46 | 47 | #: includes/class-portfolio-post-type-post-type.php:42 48 | msgctxt "add new on admin bar" 49 | msgid "Portfolio Item" 50 | msgstr "Item de Portfólio" 51 | 52 | #: includes/class-portfolio-post-type-post-type.php:43 53 | msgid "Add New Item" 54 | msgstr "Adicionar novo item" 55 | 56 | #: includes/class-portfolio-post-type-post-type.php:44 57 | #: includes/class-portfolio-post-type-post-type.php:45 58 | msgid "Add New Portfolio Item" 59 | msgstr "Adicionar novo item de Portfólio" 60 | 61 | #: includes/class-portfolio-post-type-post-type.php:46 62 | msgid "Edit Portfolio Item" 63 | msgstr "Editar item de Portfólio" 64 | 65 | #: includes/class-portfolio-post-type-post-type.php:47 66 | msgid "View Item" 67 | msgstr "Ver item" 68 | 69 | #: includes/class-portfolio-post-type-post-type.php:48 70 | msgid "All Portfolio Items" 71 | msgstr "Todos os itens de Portfólio" 72 | 73 | #: includes/class-portfolio-post-type-post-type.php:49 74 | msgid "Search Portfolio" 75 | msgstr "Procurar no Porftólio" 76 | 77 | #: includes/class-portfolio-post-type-post-type.php:50 78 | msgid "Parent Portfolio Item:" 79 | msgstr "Item superior de Portfólio:" 80 | 81 | #: includes/class-portfolio-post-type-post-type.php:51 82 | msgid "No portfolio items found" 83 | msgstr "Nenhum item de Portfólio encontrado" 84 | 85 | #: includes/class-portfolio-post-type-post-type.php:52 86 | msgid "No portfolio items found in trash" 87 | msgstr "Nenhum item de Portfólio encontrado no lixo" 88 | 89 | #: includes/class-portfolio-post-type-post-type.php:53 90 | msgid "Filter portfolio items list" 91 | msgstr "Filtrar lista de itens de Portfólio" 92 | 93 | #: includes/class-portfolio-post-type-post-type.php:54 94 | msgid "Portfolio items list navigation" 95 | msgstr "Navegação da lista de itens de Portfólio" 96 | 97 | #: includes/class-portfolio-post-type-post-type.php:55 98 | msgid "Portfolio items list" 99 | msgstr "Lista de itens de Porftólio" 100 | 101 | #: includes/class-portfolio-post-type-post-type.php:97 102 | #: includes/class-portfolio-post-type-post-type.php:100 103 | msgid "Portfolio item updated." 104 | msgstr "Item de Portfólio actualizado." 105 | 106 | #: includes/class-portfolio-post-type-post-type.php:98 107 | msgid "Custom field updated." 108 | msgstr "Campo personalizado actualizado." 109 | 110 | #: includes/class-portfolio-post-type-post-type.php:99 111 | msgid "Custom field deleted." 112 | msgstr "Campo personalizado removido." 113 | 114 | #. translators: %s: date and time of the revision 115 | #: includes/class-portfolio-post-type-post-type.php:102 116 | #, php-format 117 | msgid "Portfolio item restored to revision from %s" 118 | msgstr "Item do Portfólio restaurado para a revisão de %s" 119 | 120 | #: includes/class-portfolio-post-type-post-type.php:103 121 | msgid "Portfolio item published." 122 | msgstr "Item de Portfólio publicado." 123 | 124 | #: includes/class-portfolio-post-type-post-type.php:104 125 | msgid "Portfolio item saved." 126 | msgstr "Item de Portfólio guardado." 127 | 128 | #: includes/class-portfolio-post-type-post-type.php:105 129 | msgid "Portfolio item submitted." 130 | msgstr "Item de Portfólio submetido." 131 | 132 | #: includes/class-portfolio-post-type-post-type.php:107 133 | #, php-format 134 | msgid "Portfolio item scheduled for: %1$s." 135 | msgstr "Item de Portfólio agendado para: %1$s." 136 | 137 | #. translators: Publish box date format, see http://php.net/date 138 | #: includes/class-portfolio-post-type-post-type.php:109 139 | msgid "M j, Y @ G:i" 140 | msgstr "j de F de Y @ G:i" 141 | 142 | #: includes/class-portfolio-post-type-post-type.php:111 143 | msgid "Portfolio item draft updated." 144 | msgstr "Rascunho do item de Portfólio actualizado." 145 | 146 | #: includes/class-portfolio-post-type-post-type.php:118 147 | msgid "View portfolio item" 148 | msgstr "Ver item de Portfólio" 149 | 150 | #: includes/class-portfolio-post-type-post-type.php:119 151 | msgid "Preview portfolio item" 152 | msgstr "Previsão de item de Portfólio" 153 | 154 | #: includes/class-portfolio-post-type-taxonomy-category.php:39 155 | #: includes/class-portfolio-post-type-taxonomy-category.php:41 156 | msgid "Portfolio Categories" 157 | msgstr "Categorias de Portfólio" 158 | 159 | #: includes/class-portfolio-post-type-taxonomy-category.php:40 160 | msgid "Portfolio Category" 161 | msgstr "Categoria de Portfólio" 162 | 163 | #: includes/class-portfolio-post-type-taxonomy-category.php:42 164 | msgid "Edit Portfolio Category" 165 | msgstr "Editar categoria de Portfólio" 166 | 167 | #: includes/class-portfolio-post-type-taxonomy-category.php:43 168 | msgid "Update Portfolio Category" 169 | msgstr "Actualizar categoria de Portfólio" 170 | 171 | #: includes/class-portfolio-post-type-taxonomy-category.php:44 172 | msgid "Add New Portfolio Category" 173 | msgstr "Adicionar nova categoria de Portfólio" 174 | 175 | #: includes/class-portfolio-post-type-taxonomy-category.php:45 176 | msgid "New Portfolio Category Name" 177 | msgstr "Nome da nova categoria de Portfólio" 178 | 179 | #: includes/class-portfolio-post-type-taxonomy-category.php:46 180 | msgid "Parent Portfolio Category" 181 | msgstr "Categoria superior de Portfólio" 182 | 183 | #: includes/class-portfolio-post-type-taxonomy-category.php:47 184 | msgid "Parent Portfolio Category:" 185 | msgstr "Categoria superior de Portfólio:" 186 | 187 | #: includes/class-portfolio-post-type-taxonomy-category.php:48 188 | msgid "All Portfolio Categories" 189 | msgstr "Todas as categorias de Portfólio" 190 | 191 | #: includes/class-portfolio-post-type-taxonomy-category.php:49 192 | msgid "Search Portfolio Categories" 193 | msgstr "Procurar categorias de Portfólio" 194 | 195 | #: includes/class-portfolio-post-type-taxonomy-category.php:50 196 | msgid "Popular Portfolio Categories" 197 | msgstr "Categorias populares de Portfólio" 198 | 199 | #: includes/class-portfolio-post-type-taxonomy-category.php:51 200 | msgid "Separate portfolio categories with commas" 201 | msgstr "Categorias de Portfólio separadas por vírgulas" 202 | 203 | #: includes/class-portfolio-post-type-taxonomy-category.php:52 204 | msgid "Add or remove portfolio categories" 205 | msgstr "Adicionar ou remover categorias de Portfólio" 206 | 207 | #: includes/class-portfolio-post-type-taxonomy-category.php:53 208 | msgid "Choose from the most used portfolio categories" 209 | msgstr "Escolha de entre as categorias de Portfólio mais usadas" 210 | 211 | #: includes/class-portfolio-post-type-taxonomy-category.php:54 212 | msgid "No portfolio categories found." 213 | msgstr "Não foram encontradas categorias de Portfólio." 214 | 215 | #: includes/class-portfolio-post-type-taxonomy-category.php:55 216 | msgid "Portfolio categories list navigation" 217 | msgstr "Navegação da lista de categorias de Portfólio" 218 | 219 | #: includes/class-portfolio-post-type-taxonomy-category.php:56 220 | msgid "Portfolio categories list" 221 | msgstr "Lista de categorias de Portfólio" 222 | 223 | #: includes/class-portfolio-post-type-taxonomy-tag.php:39 224 | #: includes/class-portfolio-post-type-taxonomy-tag.php:41 225 | msgid "Portfolio Tags" 226 | msgstr "Etiquetas de Portfólio" 227 | 228 | #: includes/class-portfolio-post-type-taxonomy-tag.php:40 229 | msgid "Portfolio Tag" 230 | msgstr "Etiqueta de Portfólio" 231 | 232 | #: includes/class-portfolio-post-type-taxonomy-tag.php:42 233 | msgid "Edit Portfolio Tag" 234 | msgstr "Editar etiqueta de Portfólio" 235 | 236 | #: includes/class-portfolio-post-type-taxonomy-tag.php:43 237 | msgid "Update Portfolio Tag" 238 | msgstr "Actualizar etiqueta de Portfólio" 239 | 240 | #: includes/class-portfolio-post-type-taxonomy-tag.php:44 241 | msgid "Add New Portfolio Tag" 242 | msgstr "Adicionar nova etiqueta de Portfólio" 243 | 244 | #: includes/class-portfolio-post-type-taxonomy-tag.php:45 245 | msgid "New Portfolio Tag Name" 246 | msgstr "Nome da nova etiqueta de Portfólio" 247 | 248 | #: includes/class-portfolio-post-type-taxonomy-tag.php:46 249 | msgid "Parent Portfolio Tag" 250 | msgstr "Etiqueta superior de Portfólio" 251 | 252 | #: includes/class-portfolio-post-type-taxonomy-tag.php:47 253 | msgid "Parent Portfolio Tag:" 254 | msgstr "Etiqueta superior de Portfólio:" 255 | 256 | #: includes/class-portfolio-post-type-taxonomy-tag.php:48 257 | msgid "All Portfolio Tags" 258 | msgstr "Todas as etiquetas de Portfólio" 259 | 260 | #: includes/class-portfolio-post-type-taxonomy-tag.php:49 261 | msgid "Search Portfolio Tags" 262 | msgstr "Procurar etiquetas de Portfólio" 263 | 264 | #: includes/class-portfolio-post-type-taxonomy-tag.php:50 265 | msgid "Popular Portfolio Tags" 266 | msgstr "Etiquetas populares de Portfólio" 267 | 268 | #: includes/class-portfolio-post-type-taxonomy-tag.php:51 269 | msgid "Separate portfolio tags with commas" 270 | msgstr "Etiquetas de Portfólio separadas por vírgulas" 271 | 272 | #: includes/class-portfolio-post-type-taxonomy-tag.php:52 273 | msgid "Add or remove portfolio tags" 274 | msgstr "Adicionar ou remover etiquetas de Portfólio" 275 | 276 | #: includes/class-portfolio-post-type-taxonomy-tag.php:53 277 | msgid "Choose from the most used portfolio tags" 278 | msgstr "Escolha de entre as etiquetas de Portfólio mais usadas" 279 | 280 | #: includes/class-portfolio-post-type-taxonomy-tag.php:54 281 | msgid "No portfolio tags found." 282 | msgstr "Não foram encontradas etiquetas de Portfólio." 283 | 284 | #: includes/class-portfolio-post-type-taxonomy-tag.php:55 285 | msgid "Portfolio tags list navigation" 286 | msgstr "Navegação da lista de etiquetas de Portfólio" 287 | 288 | #: includes/class-portfolio-post-type-taxonomy-tag.php:56 289 | msgid "Portfolio tags list" 290 | msgstr "Lista de etiquetas de Portfólio" 291 | 292 | #. Plugin Name of the plugin/theme 293 | msgid "Portfolio Post Type" 294 | msgstr "Portfolio Post Type" 295 | 296 | #. Plugin URI of the plugin/theme 297 | msgid "http://wptheming.com/portfolio-post-type/" 298 | msgstr "http://wptheming.com/portfolio-post-type/" 299 | 300 | #. Description of the plugin/theme 301 | msgid "Enables a portfolio post type and taxonomies." 302 | msgstr "" 303 | "Permite acrescentar um tipo de artigo de Porftólio e respectivas " 304 | "taxonomias." 305 | 306 | #. Author of the plugin/theme 307 | msgid "Devin Price" 308 | msgstr "Devin Price" 309 | 310 | #. Author URI of the plugin/theme 311 | msgid "http://www.wptheming.com/" 312 | msgstr "http://www.wptheming.com/" 313 | -------------------------------------------------------------------------------- /languages/portfolio-post-type-sv_SE.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinsays/portfolio-post-type/42c9fd29660640867898e01323b6f74303145bf9/languages/portfolio-post-type-sv_SE.mo -------------------------------------------------------------------------------- /languages/portfolio-post-type-sv_SE.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: Portfolio Post Type\n" 4 | "POT-Creation-Date: 2013-02-19 11:32+0100\n" 5 | "PO-Revision-Date: 2013-02-19 11:46+0100\n" 6 | "Last-Translator: Andréas Lundgren \n" 7 | "Language-Team: \n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "X-Generator: Poedit 1.5.5\n" 12 | "X-Poedit-KeywordsList: __;_e;_n;_x\n" 13 | "X-Poedit-Basepath: .\n" 14 | "X-Poedit-SourceCharset: UTF-8\n" 15 | "X-Poedit-SearchPath-0: .\n" 16 | 17 | #: portfolio-post-type.php:65 18 | msgid "Portfolio" 19 | msgstr "Portfolio" 20 | 21 | #: portfolio-post-type.php:66 portfolio-post-type.php:230 22 | msgid "Portfolio Item" 23 | msgstr "Portfolioobjekt" 24 | 25 | #: portfolio-post-type.php:67 26 | msgid "Add New Item" 27 | msgstr "Lägg till nytt objekt" 28 | 29 | #: portfolio-post-type.php:68 portfolio-post-type.php:70 30 | msgid "Add New Portfolio Item" 31 | msgstr "Lägg till nytt objekt i portfolion" 32 | 33 | #: portfolio-post-type.php:69 34 | msgid "Edit Portfolio Item" 35 | msgstr "Redigera portfolioobjekt" 36 | 37 | #: portfolio-post-type.php:71 38 | msgid "View Item" 39 | msgstr "Visa objekt" 40 | 41 | #: portfolio-post-type.php:72 42 | msgid "Search Portfolio" 43 | msgstr "Sök i portfolio" 44 | 45 | #: portfolio-post-type.php:73 46 | msgid "No portfolio items found" 47 | msgstr "Inga objekt hittades." 48 | 49 | #: portfolio-post-type.php:74 50 | msgid "No portfolio items found in trash" 51 | msgstr "Inga objekt hittades i papperskorgen." 52 | 53 | #: portfolio-post-type.php:97 portfolio-post-type.php:111 54 | msgid "Portfolio Tags" 55 | msgstr "Portfolioetiketter" 56 | 57 | #: portfolio-post-type.php:98 58 | msgid "Portfolio Tag" 59 | msgstr "Portfolioetikett" 60 | 61 | #: portfolio-post-type.php:99 62 | msgid "Search Portfolio Tags" 63 | msgstr "Sök bland portfolioetiketter" 64 | 65 | #: portfolio-post-type.php:100 66 | msgid "Popular Portfolio Tags" 67 | msgstr "Populära portfolioetiketter" 68 | 69 | #: portfolio-post-type.php:101 70 | msgid "All Portfolio Tags" 71 | msgstr "Alla portfolioetiketter" 72 | 73 | #: portfolio-post-type.php:102 74 | msgid "Parent Portfolio Tag" 75 | msgstr "Förälder till portfolioetikett" 76 | 77 | #: portfolio-post-type.php:103 78 | msgid "Parent Portfolio Tag:" 79 | msgstr "Förälder till portfolioetikett:" 80 | 81 | #: portfolio-post-type.php:104 82 | msgid "Edit Portfolio Tag" 83 | msgstr "Redigera portfolioetikett" 84 | 85 | #: portfolio-post-type.php:105 86 | msgid "Update Portfolio Tag" 87 | msgstr "Uppdatera portfolioetikett" 88 | 89 | #: portfolio-post-type.php:106 90 | msgid "Add New Portfolio Tag" 91 | msgstr "Lägg till ny portfolioetikett" 92 | 93 | #: portfolio-post-type.php:107 94 | msgid "New Portfolio Tag Name" 95 | msgstr "Nytt namn på portfolioetikett" 96 | 97 | #: portfolio-post-type.php:108 98 | msgid "Separate portfolio tags with commas" 99 | msgstr "Separera flera portfolioetiketter med komma" 100 | 101 | #: portfolio-post-type.php:109 102 | msgid "Add or remove portfolio tags" 103 | msgstr "Lägg till eller ta bort portfolioetiketter" 104 | 105 | #: portfolio-post-type.php:110 106 | msgid "Choose from the most used portfolio tags" 107 | msgstr "Välj från de populäraste portfolioetiketterna" 108 | 109 | #: portfolio-post-type.php:134 portfolio-post-type.php:148 110 | msgid "Portfolio Categories" 111 | msgstr "Portfoliokategorier" 112 | 113 | #: portfolio-post-type.php:135 114 | msgid "Portfolio Category" 115 | msgstr "Portfoliokategori" 116 | 117 | #: portfolio-post-type.php:136 118 | msgid "Search Portfolio Categories" 119 | msgstr "Sök bland portfoliokategorier" 120 | 121 | #: portfolio-post-type.php:137 122 | msgid "Popular Portfolio Categories" 123 | msgstr "Populära portfoliokategorier" 124 | 125 | #: portfolio-post-type.php:138 126 | msgid "All Portfolio Categories" 127 | msgstr "Alla portfoliokategorier" 128 | 129 | #: portfolio-post-type.php:139 130 | msgid "Parent Portfolio Category" 131 | msgstr "Förälder till portfoliokategori" 132 | 133 | #: portfolio-post-type.php:140 134 | msgid "Parent Portfolio Category:" 135 | msgstr "Förälder till portfoliokategori:" 136 | 137 | #: portfolio-post-type.php:141 138 | msgid "Edit Portfolio Category" 139 | msgstr "Redigera portfoliokategori" 140 | 141 | #: portfolio-post-type.php:142 142 | msgid "Update Portfolio Category" 143 | msgstr "Uppdatera portfoliokategori" 144 | 145 | #: portfolio-post-type.php:143 146 | msgid "Add New Portfolio Category" 147 | msgstr "Lägg till ny portfoliokategori" 148 | 149 | #: portfolio-post-type.php:144 150 | msgid "New Portfolio Category Name" 151 | msgstr "Nytt namn på portfoliokategori" 152 | 153 | #: portfolio-post-type.php:145 154 | msgid "Separate portfolio categories with commas" 155 | msgstr "Separera flera portfoliokategorier med komma" 156 | 157 | #: portfolio-post-type.php:146 158 | msgid "Add or remove portfolio categories" 159 | msgstr "Lägg till eller ta bort portfoliokategorier" 160 | 161 | #: portfolio-post-type.php:147 162 | msgid "Choose from the most used portfolio categories" 163 | msgstr "Välj från de populäraste portfoliokategorierna" 164 | 165 | #: portfolio-post-type.php:174 166 | msgid "Thumbnail" 167 | msgstr "Miniatyrbild" 168 | 169 | #: portfolio-post-type.php:241 170 | msgid "Portfolio Item Pending" 171 | msgstr "Portfolioobjekt väntar på granskning" 172 | -------------------------------------------------------------------------------- /languages/portfolio-post-type.pot: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Devin Price 2 | # This file is distributed under the GPL-2.0+. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: Portfolio Post Type 0.9.1\n" 6 | "Report-Msgid-Bugs-To: " 7 | "http://wordpress.org/support/plugin/portfolio-post-type\n" 8 | "POT-Creation-Date: 2015-12-27 19:55:17+00:00\n" 9 | "MIME-Version: 1.0\n" 10 | "Content-Type: text/plain; charset=utf-8\n" 11 | "Content-Transfer-Encoding: 8bit\n" 12 | "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "X-Generator: grunt-wp-i18n 0.4.9\n" 16 | 17 | #: includes/class-portfolio-post-type-admin.php:68 18 | msgid "Thumbnail" 19 | msgstr "" 20 | 21 | #: includes/class-portfolio-post-type-post-type.php:39 22 | msgid "Portfolio" 23 | msgstr "" 24 | 25 | #: includes/class-portfolio-post-type-post-type.php:40 26 | msgid "Portfolio Item" 27 | msgstr "" 28 | 29 | #: includes/class-portfolio-post-type-post-type.php:43 30 | msgid "Add New Item" 31 | msgstr "" 32 | 33 | #: includes/class-portfolio-post-type-post-type.php:44 34 | #: includes/class-portfolio-post-type-post-type.php:45 35 | msgid "Add New Portfolio Item" 36 | msgstr "" 37 | 38 | #: includes/class-portfolio-post-type-post-type.php:46 39 | msgid "Edit Portfolio Item" 40 | msgstr "" 41 | 42 | #: includes/class-portfolio-post-type-post-type.php:47 43 | msgid "View Item" 44 | msgstr "" 45 | 46 | #: includes/class-portfolio-post-type-post-type.php:48 47 | msgid "All Portfolio Items" 48 | msgstr "" 49 | 50 | #: includes/class-portfolio-post-type-post-type.php:49 51 | msgid "Search Portfolio" 52 | msgstr "" 53 | 54 | #: includes/class-portfolio-post-type-post-type.php:50 55 | msgid "Parent Portfolio Item:" 56 | msgstr "" 57 | 58 | #: includes/class-portfolio-post-type-post-type.php:51 59 | msgid "No portfolio items found" 60 | msgstr "" 61 | 62 | #: includes/class-portfolio-post-type-post-type.php:52 63 | msgid "No portfolio items found in trash" 64 | msgstr "" 65 | 66 | #: includes/class-portfolio-post-type-post-type.php:53 67 | msgid "Filter portfolio items list" 68 | msgstr "" 69 | 70 | #: includes/class-portfolio-post-type-post-type.php:54 71 | msgid "Portfolio items list navigation" 72 | msgstr "" 73 | 74 | #: includes/class-portfolio-post-type-post-type.php:55 75 | msgid "Portfolio items list" 76 | msgstr "" 77 | 78 | #: includes/class-portfolio-post-type-post-type.php:97 79 | #: includes/class-portfolio-post-type-post-type.php:100 80 | msgid "Portfolio item updated." 81 | msgstr "" 82 | 83 | #: includes/class-portfolio-post-type-post-type.php:98 84 | msgid "Custom field updated." 85 | msgstr "" 86 | 87 | #: includes/class-portfolio-post-type-post-type.php:99 88 | msgid "Custom field deleted." 89 | msgstr "" 90 | 91 | #: includes/class-portfolio-post-type-post-type.php:102 92 | #. translators: %s: date and time of the revision 93 | msgid "Portfolio item restored to revision from %s" 94 | msgstr "" 95 | 96 | #: includes/class-portfolio-post-type-post-type.php:103 97 | msgid "Portfolio item published." 98 | msgstr "" 99 | 100 | #: includes/class-portfolio-post-type-post-type.php:104 101 | msgid "Portfolio item saved." 102 | msgstr "" 103 | 104 | #: includes/class-portfolio-post-type-post-type.php:105 105 | msgid "Portfolio item submitted." 106 | msgstr "" 107 | 108 | #: includes/class-portfolio-post-type-post-type.php:107 109 | msgid "Portfolio item scheduled for: %1$s." 110 | msgstr "" 111 | 112 | #: includes/class-portfolio-post-type-post-type.php:109 113 | #. translators: Publish box date format, see http:php.net/date 114 | msgid "M j, Y @ G:i" 115 | msgstr "" 116 | 117 | #: includes/class-portfolio-post-type-post-type.php:111 118 | msgid "Portfolio item draft updated." 119 | msgstr "" 120 | 121 | #: includes/class-portfolio-post-type-post-type.php:118 122 | msgid "View portfolio item" 123 | msgstr "" 124 | 125 | #: includes/class-portfolio-post-type-post-type.php:119 126 | msgid "Preview portfolio item" 127 | msgstr "" 128 | 129 | #: includes/class-portfolio-post-type-taxonomy-category.php:39 130 | #: includes/class-portfolio-post-type-taxonomy-category.php:41 131 | msgid "Portfolio Categories" 132 | msgstr "" 133 | 134 | #: includes/class-portfolio-post-type-taxonomy-category.php:40 135 | msgid "Portfolio Category" 136 | msgstr "" 137 | 138 | #: includes/class-portfolio-post-type-taxonomy-category.php:42 139 | msgid "Edit Portfolio Category" 140 | msgstr "" 141 | 142 | #: includes/class-portfolio-post-type-taxonomy-category.php:43 143 | msgid "Update Portfolio Category" 144 | msgstr "" 145 | 146 | #: includes/class-portfolio-post-type-taxonomy-category.php:44 147 | msgid "Add New Portfolio Category" 148 | msgstr "" 149 | 150 | #: includes/class-portfolio-post-type-taxonomy-category.php:45 151 | msgid "New Portfolio Category Name" 152 | msgstr "" 153 | 154 | #: includes/class-portfolio-post-type-taxonomy-category.php:46 155 | msgid "Parent Portfolio Category" 156 | msgstr "" 157 | 158 | #: includes/class-portfolio-post-type-taxonomy-category.php:47 159 | msgid "Parent Portfolio Category:" 160 | msgstr "" 161 | 162 | #: includes/class-portfolio-post-type-taxonomy-category.php:48 163 | msgid "All Portfolio Categories" 164 | msgstr "" 165 | 166 | #: includes/class-portfolio-post-type-taxonomy-category.php:49 167 | msgid "Search Portfolio Categories" 168 | msgstr "" 169 | 170 | #: includes/class-portfolio-post-type-taxonomy-category.php:50 171 | msgid "Popular Portfolio Categories" 172 | msgstr "" 173 | 174 | #: includes/class-portfolio-post-type-taxonomy-category.php:51 175 | msgid "Separate portfolio categories with commas" 176 | msgstr "" 177 | 178 | #: includes/class-portfolio-post-type-taxonomy-category.php:52 179 | msgid "Add or remove portfolio categories" 180 | msgstr "" 181 | 182 | #: includes/class-portfolio-post-type-taxonomy-category.php:53 183 | msgid "Choose from the most used portfolio categories" 184 | msgstr "" 185 | 186 | #: includes/class-portfolio-post-type-taxonomy-category.php:54 187 | msgid "No portfolio categories found." 188 | msgstr "" 189 | 190 | #: includes/class-portfolio-post-type-taxonomy-category.php:55 191 | msgid "Portfolio categories list navigation" 192 | msgstr "" 193 | 194 | #: includes/class-portfolio-post-type-taxonomy-category.php:56 195 | msgid "Portfolio categories list" 196 | msgstr "" 197 | 198 | #: includes/class-portfolio-post-type-taxonomy-tag.php:39 199 | #: includes/class-portfolio-post-type-taxonomy-tag.php:41 200 | msgid "Portfolio Tags" 201 | msgstr "" 202 | 203 | #: includes/class-portfolio-post-type-taxonomy-tag.php:40 204 | msgid "Portfolio Tag" 205 | msgstr "" 206 | 207 | #: includes/class-portfolio-post-type-taxonomy-tag.php:42 208 | msgid "Edit Portfolio Tag" 209 | msgstr "" 210 | 211 | #: includes/class-portfolio-post-type-taxonomy-tag.php:43 212 | msgid "Update Portfolio Tag" 213 | msgstr "" 214 | 215 | #: includes/class-portfolio-post-type-taxonomy-tag.php:44 216 | msgid "Add New Portfolio Tag" 217 | msgstr "" 218 | 219 | #: includes/class-portfolio-post-type-taxonomy-tag.php:45 220 | msgid "New Portfolio Tag Name" 221 | msgstr "" 222 | 223 | #: includes/class-portfolio-post-type-taxonomy-tag.php:46 224 | msgid "Parent Portfolio Tag" 225 | msgstr "" 226 | 227 | #: includes/class-portfolio-post-type-taxonomy-tag.php:47 228 | msgid "Parent Portfolio Tag:" 229 | msgstr "" 230 | 231 | #: includes/class-portfolio-post-type-taxonomy-tag.php:48 232 | msgid "All Portfolio Tags" 233 | msgstr "" 234 | 235 | #: includes/class-portfolio-post-type-taxonomy-tag.php:49 236 | msgid "Search Portfolio Tags" 237 | msgstr "" 238 | 239 | #: includes/class-portfolio-post-type-taxonomy-tag.php:50 240 | msgid "Popular Portfolio Tags" 241 | msgstr "" 242 | 243 | #: includes/class-portfolio-post-type-taxonomy-tag.php:51 244 | msgid "Separate portfolio tags with commas" 245 | msgstr "" 246 | 247 | #: includes/class-portfolio-post-type-taxonomy-tag.php:52 248 | msgid "Add or remove portfolio tags" 249 | msgstr "" 250 | 251 | #: includes/class-portfolio-post-type-taxonomy-tag.php:53 252 | msgid "Choose from the most used portfolio tags" 253 | msgstr "" 254 | 255 | #: includes/class-portfolio-post-type-taxonomy-tag.php:54 256 | msgid "No portfolio tags found." 257 | msgstr "" 258 | 259 | #: includes/class-portfolio-post-type-taxonomy-tag.php:55 260 | msgid "Portfolio tags list navigation" 261 | msgstr "" 262 | 263 | #: includes/class-portfolio-post-type-taxonomy-tag.php:56 264 | msgid "Portfolio tags list" 265 | msgstr "" 266 | 267 | #. Plugin Name of the plugin/theme 268 | msgid "Portfolio Post Type" 269 | msgstr "" 270 | 271 | #. Plugin URI of the plugin/theme 272 | msgid "http://wptheming.com/portfolio-post-type/" 273 | msgstr "" 274 | 275 | #. Description of the plugin/theme 276 | msgid "Enables a portfolio post type and taxonomies." 277 | msgstr "" 278 | 279 | #. Author of the plugin/theme 280 | msgid "Devin Price" 281 | msgstr "" 282 | 283 | #. Author URI of the plugin/theme 284 | msgid "http://www.wptheming.com/" 285 | msgstr "" 286 | 287 | #: includes/class-portfolio-post-type-post-type.php:41 288 | msgctxt "admin menu" 289 | msgid "Portfolio" 290 | msgstr "" 291 | 292 | #: includes/class-portfolio-post-type-post-type.php:42 293 | msgctxt "add new on admin bar" 294 | msgid "Portfolio Item" 295 | msgstr "" -------------------------------------------------------------------------------- /phpcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | */.git/* 12 | .github/ 13 | */vendor/* 14 | */node_modules/* 15 | */tests/* 16 | */bin/* 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | . 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | tests/unit/ 12 | 13 | 14 | tests/integration/ 15 | 16 | 17 | 18 | 19 | 20 | includes/ 21 | uninstall.php 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /portfolio-post-type.php: -------------------------------------------------------------------------------- 1 | init(); 53 | 54 | add_action( 'init', 'portfolio_post_type_init', 100 ); 55 | /** 56 | * Adds styling to the dashboard for the post type and adds portfolio posts 57 | * to the "At a Glance" metabox. 58 | * 59 | * Adds custom taxonomy body classes to portfolio posts on the front end. 60 | * 61 | * @since 0.8.3 62 | */ 63 | function portfolio_post_type_init() { 64 | if ( is_admin() ) { 65 | global $portfolio_post_type_admin, $portfolio_post_type_registrations; 66 | // Loads for users viewing the WordPress dashboard. 67 | if ( ! class_exists( 'Gamajo_Dashboard_Glancer' ) ) { 68 | require plugin_dir_path( __FILE__ ) . 'includes/class-gamajo-dashboard-glancer.php'; // WP 3.8 69 | } 70 | require plugin_dir_path( __FILE__ ) . 'includes/class-portfolio-post-type-admin.php'; 71 | $portfolio_post_type_admin = new Portfolio_Post_Type_Admin( $portfolio_post_type_registrations ); 72 | $portfolio_post_type_admin->init(); 73 | } else { 74 | // Loads for users viewing the front end. 75 | if ( apply_filters( 'portfolioposttype_add_taxonomy_terms_classes', true ) ) { 76 | if ( ! class_exists( 'Gamajo_Single_Entry_Term_Body_Classes' ) ) { 77 | require plugin_dir_path( __FILE__ ) . 'includes/class-gamajo-single-entry-term-body-classes.php'; 78 | } 79 | $portfolio_post_type_body_classes = new Gamajo_Single_Entry_Term_Body_Classes(); 80 | $portfolio_post_type_body_classes->init( 'portfolio' ); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === Portfolio Post Type === 2 | Contributors: downstairsdev, GaryJ 3 | Tags: portfolio, post type 4 | Requires at least: 3.8 5 | Tested up to: 5.5 6 | Stable tag: 1.0.1 7 | License: GPLv2 or later 8 | 9 | == Description == 10 | 11 | This plugin registers a custom post type for portfolio items. It also registers separate portfolio taxonomies for tags and categories. If featured images are selected, they will be displayed in the column view. 12 | 13 | This plugin doesn't change how portfolio items are displayed in your theme. You'll need to add templates for archive-portfolio.php and single-portfolio.php if you want to customize the display of portfolio items. 14 | 15 | == Installation == 16 | 17 | Just install and activate. 18 | 19 | == Frequently Asked Questions == 20 | 21 | = How can I display portfolio items differently than regular posts? = 22 | 23 | You will need to get your hands dirty with a little code and create a archive-portfolio.php template (for displaying multiple items) and a single-portfolio.php (for displaying the single item). 24 | 25 | = Why did you make this? = 26 | 27 | To allow users of Portfolio Press to more easily migrate to a new theme. And hopefully, to save some work for other folks trying to set a portfolio. 28 | 29 | = Is this code on GitHub? = 30 | 31 | Of course: [https://github.com/devinsays/portfolio-post-type](https://github.com/devinsays/portfolio-post-type) 32 | 33 | == Changelog == 34 | 35 | = 1.1.1 = 36 | 37 | * Update: Tested to version. 38 | 39 | = 1.1 = 40 | 41 | * Update: GraphQL support. Props @gabacode. 42 | * Update: Bump WordPress support versions. 43 | 44 | = 1.0.1 = 45 | 46 | * Update: Show portfolio icon in dashboard glance. Removed by mistake in v1.0.0, props @chesio for bug report. 47 | * Update: Fix for PHP 7.4.9 notices 48 | 49 | = 1.0.0 = 50 | 51 | * Update: WordPress 5.0 Editor Support (props @simube) 52 | * Update: Use filter rather than action for dashboard glance (props @chesio) 53 | 54 | = 0.9.3 = 55 | 56 | * Fix notice in dashboard when used with PHP7 57 | * Fix notice on specific screens when $screen variable not available 58 | 59 | = 0.9.2 = 60 | 61 | * Update post type messages for WordPress 4.4 62 | 63 | = 0.9.1 = 64 | 65 | * Updated translation file 66 | * Fixes issue with thumbnail support in some themes 67 | 68 | = 0.9.0 = 69 | 70 | * Remove legacy support for icons 71 | * Gamajo_Registerable interface and classes 72 | 73 | = 0.8.2 = 74 | 75 | * Updated .pot file for translations 76 | * Portuguese translation by Pedro Mendonça 77 | 78 | = 0.8.1 = 79 | 80 | * Fix for developer notices on admin pages 81 | 82 | = 0.8.0 = 83 | 84 | * Fix for taxonomy body classes on portfolio posts 85 | 86 | = 0.7.0 = 87 | 88 | * Code refactor by @garyj 89 | * Update icons for WordPress 3.8 90 | 91 | = 0.6.2 = 92 | 93 | * Fix for portfolio post type search in the dashboard. Props @pdme. 94 | * Minor code improvement for taxonomy body class filter. Props @garyj. 95 | 96 | = 0.6.1 = 97 | 98 | * Taxonomy body classes when is_single(), fixes debug notices 99 | 100 | = 0.6 = 101 | 102 | * Added @garyj as a contributor (Welcome!) 103 | * Updated to proper coding standards 104 | * Updated inline documentation 105 | * New filters for taxonomy arguments 106 | * Added body classes for custom taxonomy terms 107 | * Refactored code to be more DRY 108 | * Added not_found label to portfolio tag taxonomy 109 | * Updated translations.pot 110 | 111 | = 0.5 = 112 | 113 | * Use show_admin_column for taxonomies (http://make.wordpress.org/core/2012/12/11/wordpress-3-5-admin-columns-for-custom-taxonomies/) rather than a custom function 114 | * Add author field custom post type 115 | * Allows $args to be filtered (https://github.com/devinsays/portfolio-post-type/issues/8) 116 | 117 | = 0.4 = 118 | 119 | * Update to use classes 120 | * Update supports to include custom fields and excerpts 121 | 122 | = 0.3 = 123 | 124 | * Added category to column view 125 | * Added portfolio count to "right now" dashboard widget (props @nickhamze) 126 | * Added contextual help on portfolio edit screen (props @nickhamze) 127 | * Now flushes rewrite rules on plugin activation 128 | 129 | = 0.2 = 130 | 131 | * Fixes for portfolio tag label 132 | * Fixes for column display of portfolio items 133 | 134 | = 0.1 = 135 | 136 | * Initial release 137 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | object = new Portfolio_Post_Type_Registrations; 10 | } 11 | 12 | public function testPostTypeIsRegistered() { 13 | $this->assertEmpty( $this->object->post_type ); 14 | 15 | $this->object->register(); 16 | 17 | $this->assertArrayHasKey( $this->object->post_type, get_post_types() ); 18 | } 19 | 20 | public function testGetPortfolioItem() { 21 | $this->object->register(); 22 | 23 | $item_args = array( 24 | 'post_type' => $this->object->post_type, 25 | 'post_title' => 'Test', 26 | ); 27 | 28 | $item = $this->factory->post->create_and_get( $item_args ); 29 | 30 | $this->assertEquals( $this->object->post_type, $item->post_type ); 31 | $this->assertEquals( 'Test', $item->post_title ); 32 | } 33 | 34 | public function tearDown() { 35 | $this->object->unregister(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /tests/integration/PortfolioTaxonomiesTest.php: -------------------------------------------------------------------------------- 1 | reg = new Portfolio_Post_Type_Registrations; 9 | } 10 | 11 | public function testTaxonomyIsRegistered() { 12 | $this->assertArrayNotHasKey( 'portfolio_category', get_taxonomies(), 'portfolio_category is registered.' ); 13 | $this->assertArrayNotHasKey( 'portfolio_tag', get_taxonomies(), 'portfolio_tag is registered.' ); 14 | $this->reg->register(); 15 | $this->assertArrayHasKey( $this->reg->taxonomies[0], get_taxonomies(), 'portfolio_category not registered.' ); 16 | $this->assertArrayHasKey( $this->reg->taxonomies[1], get_taxonomies(), 'portfolio_tag not registered.' ); 17 | } 18 | 19 | public function tearDown() { 20 | $this->reg->unregister(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /tests/unit/GamajoPostTypeTest.php: -------------------------------------------------------------------------------- 1 | getMockForAbstractClass( 'Gamajo_Post_Type' ); 7 | $stub->expects( $this->any()) 8 | ->method( 'default_args' ) 9 | ->will( $this->returnValue( array() ) ); 10 | 11 | $stub->set_args( array() ); 12 | $this->assertCount( 0, $stub->get_args() ); 13 | $this->assertEqualSets( array(), $stub->get_args() ); 14 | 15 | $stub->set_args( array( 'foo' ) ); 16 | $this->assertCount( 1, $stub->get_args() ); 17 | $this->assertEqualSets( array( 'foo' ), $stub->get_args() ); 18 | 19 | $stub->set_args( array( 'foo' => 'bar' ) ); 20 | $this->assertCount( 1, $stub->get_args() ); 21 | $this->assertEqualSets( array( 'foo' => 'bar' ), $stub->get_args() ); 22 | } 23 | 24 | public function testGetSetArgsPopulatedDefaults() { 25 | $stub = $this->getMockForAbstractClass( 'Gamajo_Post_Type' ); 26 | $stub->expects( $this->any()) 27 | ->method( 'default_args' ) 28 | ->will( $this->returnValue( array( 'baz' => 'x' ) ) ); 29 | 30 | $stub->set_args( array() ); 31 | $this->assertCount( 1, $stub->get_args() ); 32 | $this->assertEqualSets( array( 'baz' => 'x' ), $stub->get_args() ); 33 | 34 | $stub->set_args( array( 'foo' ) ); 35 | $this->assertCount( 2, $stub->get_args() ); 36 | $this->assertEqualSets( array( 'foo', 'baz' => 'x' ), $stub->get_args() ); 37 | 38 | $stub->set_args( array( 'foo' => 'bar' ) ); 39 | $this->assertCount( 2, $stub->get_args() ); 40 | $this->assertEqualSets( array( 'foo' => 'bar', 'baz' => 'x' ), $stub->get_args() ); 41 | 42 | $stub->set_args( array( 'baz' => 'y' ) ); 43 | $this->assertCount( 1, $stub->get_args() ); 44 | $this->assertEqualSets( array( 'baz' => 'y' ), $stub->get_args() ); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /tests/unit/PortfolioAdminTest.php: -------------------------------------------------------------------------------- 1 | admin = new Portfolio_Post_Type_Admin( null ); 10 | } 11 | 12 | public function testBuildTermOptions() { 13 | $method = new ReflectionMethod( 'Portfolio_Post_Type_Admin', 'build_term_options' ); 14 | $method->setAccessible( true ); 15 | 16 | // Testing the ability to build options, so mock term objects 17 | $foo = $this->createTerm( 'foo', 'Foo', 1 ); 18 | $bar = $this->createTerm( 'bar', 'Bar', 2 ); 19 | $baz = $this->createTerm( 'baz', 'Baz', 3 ); 20 | 21 | $expected = ''; 22 | $results = $method->invoke( $this->admin, array( $foo, $bar, $baz ), 'bar' ); 23 | $this->assertEquals( $expected, $results ); 24 | } 25 | 26 | private function createTerm( $slug, $name, $count ) { 27 | $term = new stdClass; 28 | $term->slug = $slug; 29 | $term->name = $name; 30 | $term->count = $count; 31 | return $term; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /tests/unit/PortfolioPostTypeUnitTest.php: -------------------------------------------------------------------------------- 1 | object = new Portfolio_Post_Type_Post_Type; 11 | 12 | $this->label_keys = array( 13 | 'name', 14 | 'singular_name', 15 | 'menu_name', 16 | 'name_admin_bar', 17 | 'add_new', 18 | 'add_new_item', 19 | 'new_item', 20 | 'edit_item', 21 | 'view_item', 22 | 'all_items', 23 | 'search_items', 24 | 'parent_item_colon', 25 | 'not_found', 26 | 'not_found_in_trash', 27 | ); 28 | } 29 | 30 | public function testPostTypeIsSet() { 31 | $this->assertObjectHasAttribute( 'post_type', $this->object ); 32 | $this->assertNotEmpty( $this->object->get_post_type() ); 33 | } 34 | 35 | public function testHasAllLabels() { 36 | $labels = $this->get_default_args()['labels']; 37 | 38 | foreach ( $this->label_keys as $label ) { 39 | $this->assertArrayHasKey( $label, $labels, "$label is not set" ); 40 | } 41 | } 42 | 43 | private function get_default_args() { 44 | $method = new ReflectionMethod( 'Portfolio_Post_Type_Post_Type', 'default_args' ); 45 | $method->setAccessible( true ); 46 | 47 | return $method->invoke( $this->object ); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /tests/unit/PortfolioTaxonomyCategoryUnitTest.php: -------------------------------------------------------------------------------- 1 | object = new Portfolio_Post_Type_Taxonomy_Category; 11 | 12 | $this->label_keys = array( 13 | 'name', 14 | 'singular_name', 15 | 'menu_name', 16 | 'edit_item', 17 | 'update_item', 18 | 'add_new_item', 19 | 'new_item_name', 20 | 'parent_item', 21 | 'parent_item_colon', 22 | 'all_items', 23 | 'search_items', 24 | 'popular_items', 25 | 'separate_items_with_commas', 26 | 'add_or_remove_items', 27 | 'choose_from_most_used', 28 | 'not_found', 29 | ); 30 | } 31 | 32 | public function testPostTypeIsSet() { 33 | $this->assertObjectHasAttribute( 'taxonomy', $this->object ); 34 | $this->assertNotEmpty( $this->object->get_taxonomy() ); 35 | } 36 | 37 | public function testHasAllLabels() { 38 | $labels = $this->get_default_args()['labels']; 39 | 40 | foreach ( $this->label_keys as $label ) { 41 | $this->assertArrayHasKey( $label, $labels, "$label is not set" ); 42 | } 43 | } 44 | 45 | private function get_default_args() { 46 | $method = new ReflectionMethod( 'Portfolio_Post_Type_Taxonomy_Category', 'default_args' ); 47 | $method->setAccessible( true ); 48 | 49 | return $method->invoke( $this->object ); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /tests/unit/PortfolioTaxonomyTagUnitTest.php: -------------------------------------------------------------------------------- 1 | object = new Portfolio_Post_Type_Taxonomy_Tag; 11 | 12 | $this->label_keys = array( 13 | 'name', 14 | 'singular_name', 15 | 'menu_name', 16 | 'edit_item', 17 | 'update_item', 18 | 'add_new_item', 19 | 'new_item_name', 20 | 'parent_item', 21 | 'parent_item_colon', 22 | 'all_items', 23 | 'search_items', 24 | 'popular_items', 25 | 'separate_items_with_commas', 26 | 'add_or_remove_items', 27 | 'choose_from_most_used', 28 | 'not_found', 29 | ); 30 | } 31 | 32 | public function testPostTypeIsSet() { 33 | $this->assertObjectHasAttribute( 'taxonomy', $this->object ); 34 | $this->assertNotEmpty( $this->object->get_taxonomy() ); 35 | } 36 | 37 | public function testHasAllLabels() { 38 | $labels = $this->get_default_args()['labels']; 39 | 40 | foreach ( $this->label_keys as $label ) { 41 | $this->assertArrayHasKey( $label, $labels, "$label is not set" ); 42 | } 43 | } 44 | 45 | private function get_default_args() { 46 | $method = new ReflectionMethod( 'Portfolio_Post_Type_Taxonomy_Tag', 'default_args' ); 47 | $method->setAccessible( true ); 48 | 49 | return $method->invoke( $this->object ); 50 | } 51 | 52 | } 53 | --------------------------------------------------------------------------------