iThemes Exchange for Developers
-
Upload
ithemes -
Category
Technology
-
view
540 -
download
0
description
Transcript of iThemes Exchange for Developers
![Page 1: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/1.jpg)
iThemes Exchangefor developers
![Page 2: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/2.jpg)
Simple ecommerce for WordPress
![Page 3: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/3.jpg)
Where do you jump in?
![Page 4: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/4.jpg)
How is Exchange Organized
● /lib
![Page 5: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/5.jpg)
How is Exchange Organized
● /lib● /api
![Page 6: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/6.jpg)
How is Exchange Organized
● /lib● /api● /core-addons
![Page 7: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/7.jpg)
How do I register an add-on?
exchange-addon-stripe/exchange-addon-stripe.php
![Page 8: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/8.jpg)
How do I generate a settings page?
exchange-addon-stripe/exchange-addon-stripe.php
![Page 9: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/9.jpg)
How do I generate a settings page?
exchange-addon-stripe/lib/addon-settings.php
![Page 10: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/10.jpg)
How do Products & Product Types work?
● All Exchange products are a single WP
post_type
● Product Features are tied to product types
● Admin UI is reactive to the registered
types
o Setup Wizard
o Sidebar
o Add / Edit products
![Page 11: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/11.jpg)
ithemes-exchange/lib/products/class.products-post-type.php
One WP post_type
How do Products & Product Types work?
![Page 12: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/12.jpg)
Admin UI is Reactive
How do Products & Product Types work?
![Page 13: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/13.jpg)
How do I register a Product Type?
ithemes-exchange/core-addons/load.php
Product Types are an add-on category
![Page 14: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/14.jpg)
How do I register a Product Type?
exchange-addon-membership/exchange-addon-membership.php
Product Types are an add-on category
![Page 15: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/15.jpg)
What are Product Features?
product_feature all the things!
ithemes-exchange/lib/product-features/
![Page 16: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/16.jpg)
How do Product Features work?
product_feature all the things!
ithemes-exchange/lib/product-features/class.downloads.php
hooked to it_exchange_enabled_addons_loaded
![Page 17: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/17.jpg)
How do Product Features work?
product_feature all the things!
ithemes-exchange/lib/product-features/
![Page 18: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/18.jpg)
How do Product Features work?
ithemes-exchange/lib/product-features/class.abstract.php
Use the Abstract Class to create Product Features
![Page 19: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/19.jpg)
How do Product Features work?
ithemes-exchange/lib/product-features/class.inventory.php
See the inventory product feature as example of abstract implementation.
![Page 20: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/20.jpg)
How do Product Features work?
product_feature all the things!
ithemes-exchange/lib/product-features/
![Page 21: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/21.jpg)
Why use our Product Feature class?
● it_exchange_product_supports_feature()
● it_exchange_product_has_feature()
● it_exchange_update_product_feature()
● it_exchange_get_product_feature()
● it_exchange_add_feature_support_to_product_type()
● it_exchange_remove_feature_support_for_product_type()
● it_exchange_product_type_supports_feature()
● it_exchange_get_registered_product_features()
It exposes your feature to all these API functions
ithemes-exchange/api/product-features.php
![Page 22: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/22.jpg)
How do I use a Product Feature?
product features API
ithemes-exchange/api/theme/products.php
![Page 23: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/23.jpg)
How do Exchange Pages work?
![Page 24: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/24.jpg)
How do Exchange Pages work?Pages have 1-3 options: Exchange, WordPress, Disabled
![Page 25: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/25.jpg)
How do I register an Exchange page?
ithemes-exchange/lib/functions/functions.php
ithemes-exchange/lib/api/pages.php
![Page 26: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/26.jpg)
How does templating work?We have #alot of template-parts
ithemes-exchange/lib/templates/http://hyperboleandahalf.blogspot.com/2010/04/alot-is-better-than-you-at-everything.html
![Page 27: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/27.jpg)
How does templating work?Standard Templating Components
ithemes-exchange/lib/templates/content-store.php
![Page 28: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/28.jpg)
How does templating work?Top Level v. Loops v. Elements ( all template-parts )
ithemes-exchange/lib/templates/content-login.php
Loops are template-parts too but their primary job is to call additional (but related) template-parts.
ithemes-exchange/lib/templates/content-login/loops/fields.php
Top
Level
Loop
![Page 29: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/29.jpg)
How does templating work?Top Level v. Loops v. Elements ( all template-parts ) Elements are usually extremely small chunks of
HTML
ithemes-exchange/lib/templates/content-login/loops/fields.phpLo
op
ithemes-exchange/lib/templates/content-login/elements/username.php
Ele
ment
![Page 30: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/30.jpg)
There are 3 ways increasingly complex ways to alter output
1. WordPress Hooks ( multiple hooks in every template part )
o Ideal for quick additions to non-distributed code
2. Overwriting individual template parts in your theme
o Ideal for theme authors or clients that have highly customized themes and may need some custom CSS classes, etc.
3. Inserting, removing, rearranging template parts with the templating API
o Ideal for add-on developers and clients that may enable additional add-ons without you in the future.
How should I modify the templates?
![Page 31: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/31.jpg)
1) WordPress Hooks (simple)
How should I modify the templates?
ithemes-exchange/lib/templates/content-registration/elements/email.php
![Page 32: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/32.jpg)
2) Overwriting template parts in your theme (moderately difficult)
How should I modify the templates?
ithemes-exchange/lib/templates/content-store/elements/featured-image.php
themes/twentythirteen-child-exchange/exchange/content-store/elements/featured-image.php
![Page 33: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/33.jpg)
2) Overwriting template parts in your theme (moderately difficult)
How should I modify the templates?
ithemes-exchange/lib/templates/content-store/elements/featured-image.php
themes/twentythirteen-child-exchange/exchange/content-store/elements/featured-image.php
Exchange looks for the template-parts in the following locations by default
1. [child-theme]/exchange/
2. [parent-theme]/exchange/
3. ithemes-exchange/lib/templates/
![Page 34: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/34.jpg)
2) Overwriting template parts in your theme (moderately difficult)
How should I modify the templates?
![Page 35: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/35.jpg)
3) Inserting / deleting / rearranging ( difficult but powerful )
How should I modify the templates?
ithemes-exchange/api/template-parts.php
![Page 36: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/36.jpg)
3) Inserting / deleting / rearranging ( difficult but powerful )
How should I modify the templates?
ithemes-exchange/lib/templates/content-login/loops/fields.php
ithemes-exchange/api/template-parts.php
![Page 37: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/37.jpg)
3) Inserting / deleting / rearranging ( difficult but powerful )
How should I modify the templates?
ithemes-exchange/lib/templates/content-login/loops/fields.php
ithemes-exchange/api/template-parts.php
![Page 38: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/38.jpg)
How should I modify the templates?
ithemes-exchange/lib/templates/content-store/elements/featured-image.php
Exchange looks for the template-parts in the following locations by default
1. [child-theme]/exchange/
2. [parent-theme]/exchange/
3. ithemes-exchange/lib/templates/
3) Inserting / deleting / rearranging ( difficult but powerful )
![Page 39: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/39.jpg)
How should I modify the templates?
ithemes-exchange/lib/templates/content-store/elements/featured-image.php
Exchange looks for the template-parts in the following locations by default
1. [child-theme]/exchange/
2. [parent-theme]/exchange/
3. locations added via the ‘it_exchange_possible_template_paths’ filter
4. ithemes-exchange/lib/templates/
3) Inserting / deleting / rearranging ( difficult but powerful )
ithemes-exchange/lib/functions/template-functions.php
![Page 40: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/40.jpg)
How should I modify the templates?
ithemes-exchange/lib/templates/content-store/elements/featured-image.php
3) Inserting / deleting / rearranging ( difficult but powerful )
ithemes-exchange/core-addons/taxes/taxes-simple/init.php
filters generated inside it_exchange_get_template_part_loops()
![Page 41: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/41.jpg)
How should I modify the templates?3) Inserting / deleting / rearranging ( difficult but powerful )
ithemes-exchange/core-addons/taxes/taxes-simple/init.php
![Page 42: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/42.jpg)
How should I modify the templates?3) Inserting / deleting / rearranging ( difficult but powerful )
before after
![Page 43: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/43.jpg)
How does the Theme API work?it_exchange( ‘context’, ‘tag’, $options );
ithemes-exchange/api/theme/
![Page 44: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/44.jpg)
How does the Theme API work?it_exchange( ‘context’, ‘tag’, $options );
ithemes-exchange/api/theme/product.php
it_exchange( ‘product’, ‘found’);
it_exchange( ‘product’, ‘description’);
![Page 45: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/45.jpg)
How does the Theme API work?it_exchange( ‘context’, ‘tag’, $options );
ithemes-exchange/api/theme/product.php
it_exchange( ‘product’, ‘baseprice’, array( ‘before’ => ‘<p>’, ‘after’ => ‘</p>’ ) );
![Page 46: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/46.jpg)
How does the Theme API work?Prefixes
ithemes-exchange/api/theme/product.php
it_exchange( ‘product’, ‘get-description’);
it_exchange( ‘product’, ‘has-description’);
it_exchange( ‘product’, ‘supports-description’);
it_exchange( ‘product’, ‘description’); // prints the description
// returns a boolean
// returns a boolean
// returns the description
![Page 47: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/47.jpg)
How does the Theme API work?A couple examples
ithemes-exchange/lib/templates/super-widget-cart.php
![Page 48: iThemes Exchange for Developers](https://reader031.fdocuments.us/reader031/viewer/2022013011/54bfe7cc4a795960198b464e/html5/thumbnails/48.jpg)
iThemes Exchangefor developers