SlideShare una empresa de Scribd logo
1 de 19
Descargar para leer sin conexión
WORDPRESS 
CUZTOM 
HELPER 
- A helper to make the life of Wordpress developers easier. 
_ Ante Primorac (@anteprimorac) 
_ Web Developer @ Slicejack 
_ 2nd WordPress Meetup Split
WHAT DO WE USE 
CUZTOM FOR? 
_ Post types 
_ Taxonomies 
_ Meta Boxes 
_ Post meta 
_ Term meta 
_ User meta
HOW TO USE CUZTOM? 
1 CLONE REPOSITORY TO INC/CUZTOM/ 
slicejack:inc ante$ git clone https://github.com/gizburdt/wp-cuztom.git cuztom 
2 CREATE CUZTOM.PHP AND LET THE MAGIC BEGIN 
<?php 
define( 'CUZTOM_TEXTDOMAIN', 'slicejack' ); 
define( 'CUZTOM_URL', get_template_directory_uri() . '/inc/cuztom' ); 
require( 'cuztom/cuztom.php' );
BOOKS LIBRARY 
1 CREATE CUSTOM POST TYPE - BOOK 
$books = new Cuztom_Post_Type( 'book', array( 
'has_archive' => true, 
'rewrite' => array( 
'slug' => 'books' 
), 
'supports' => array( 'title', 'editor', 'thumbnail', 'revisions' ) 
) );
BOOKS LIBRARY 
2 CREATE CUSTOM TAXONOMY - BOOK CATEGORY 
$book_category = new Cuztom_Taxonomy( 'Book Category', 'book' );
BOOKS LIBRARY 
3 CREATE METABOX - INFO 
$books->add_meta_box( 
'info', 
'Info', 
array( 
array( 
'name' => 'author', 
'label' => 'Author', 
'type' => 'text' 
), 
array( 
'name' => 'date', 
'label' => 'Date', 
'type' => 'date' 
), 
array( 
'name' => 'price', 
'label' => 'Price', 
'type' => 'text' 
), 
array( 
'name' => 'number_of_pages', 
'label' => 'Number of pages', 
'type' => 'text' 
), 
array( 
'name' => 'bind_type', 
'label' => 'Bind type', 
'type' => 'select', 
'options' => array( 
'hardcover' => 'Hardcover', 
'double-wire' => 'Double wire', 
'spiral' => 'Spiral' 
), 
'default_value' => 'hardcover' 
), 
array( 
'name' => 'size', 
'label' => 'Size', 
'type' => 'select', 
'options' => array( 
'a5' => 'A5', 
'a4' => 'A4', 
'a3' => 'A3' 
), 
'default_value' => 'a4' 
) 
) 
);
FIELD TYPES 
_ text - a simple text field 
_ textarea - a large textarea for multiple lines of text 
_ checkbox - a simple boolean entry 
_ yesno - allows choice of yes/no (pre-made extension of radio) 
_ select - combo box selection 
_ multi_select - multi select selection 
_ checkboxes - a checkbox group 
_ radios - a radio group 
_ wysiwyg - an editor with the same controls as the standard WordPress editor 
_ image - image upload box 
_ file - file upload box 
_ date - date selection 
_ datetime - date and time (hour+minutes) selection 
_ time - time (hour+minutes) selection 
_ color - color selection 
_ post_select - allows inner-post references via a combo-box 
_ post_checkboxes - allows inner-post references via a checkbox group 
_ term_select - allows category references via a combo-box 
_ term_checkboxes - allows category references via a checkbox group 
_ hidden - a hidden field (oſten used to store information not visible to the user).
BOOKS LIBRARY 
4 TEMPLATE 
<div class="entry-content"> 
<?php 
$bind_types = array( 
'hardcover' => __( 'Hardcover', 'slicejack' ), 
'double-wire' => __( 'Double wire', 'slicejack' ), 
'spiral' => __( 'Spiral', 'slicejack' ) 
); 
$sizes = array( 
'a5' => __( 'A5', 'slicejack' ), 
'a4' => __( 'A4', 'slicejack' ), 
'a3' => __( 'A3', 'slicejack' ) 
); 
?> 
<strong><?php _e( 'Author:', 'slicejack' ); ?></strong> <?php echo get_post_meta( get_the_id(), 
'_info_author', true ); ?><br /> 
<strong><?php _e( 'Date:', 'slicejack' ); ?></strong> <?php echo date( 'd.m.Y.', 
get_post_meta( get_the_id(), '_info_date', true ) ); ?><br /> 
<strong><?php _e( 'Price:', 'slicejack' ); ?></strong> $<?php echo get_post_meta( get_the_id(), 
'_info_price', true ); ?><br /> 
<strong><?php _e( 'Number of pages:', 'slicejack' ); ?></strong> <?php echo 
get_post_meta( get_the_id(), '_info_number_of_pages', true ); ?><br /> 
<strong><?php _e( 'Bind type:', 'slicejack' ); ?></strong> <?php echo 
$bind_types[ get_post_meta( get_the_id(), '_info_bind_type', true ) ]; ?><br /> 
<strong><?php _e( 'Size:', 'slicejack' ); ?></strong> <?php echo 
$sizes[ get_post_meta( get_the_id(), '_info_size', true ) ]; ?> 
</div><!-- .entry-content -->
FEATURED LIBRARY 
1 ADD METABOX TO PAGE TEMPLATE 
if ( is_admin() ) : 
$pid = 0; 
if( array_key_exists( 'post', $_GET ) ) 
$pid = $_GET['post']; 
elseif ( array_key_exists( 'post_ID', $_POST ) ) 
$pid = $_POST['post_ID']; 
$page_template = basename( get_post_meta( $pid, '_wp_page_template', true ) ); 
if ( 'featured-library.php' == $page_template ) : $cpage = new Cuztom_Post_Type( 'page' ); 
$cpage 
->remove_post_type_support( array( 'editor', 'thumbnail' ) ) 
->add_meta_box( 
'library', 
'Library', 
array( 
'bundle', 
array( 
array( 
'name' => 'book', 
'label' => 'Book', 
'type' => 'post_select', 
'args' => array( 
'post_type' => 'book', 
'show_option_none' => 'None' 
) 
)
FEATURED LIBRARY 
2 PAGE TEMPLATE 
<?php 
// Start the Loop. 
while ( have_posts() ) : the_post(); 
?> 
<?php 
the_title( '<header class="entry-header"><h1 class="entry-title">', '</h1></ 
header><!-- .entry-header -->' ); 
?> 
<?php 
$library = get_post_meta( get_the_id(), '_library', true ); 
foreach( $library as $book ) : 
$post = get_post( $book['_book'] ); 
setup_postdata( $post ); 
get_template_part( 'book' ); 
endforeach; 
wp_reset_postdata(); 
endwhile; 
?>
CUSTOM FIELD TYPE 
1 CREATE YOURFIELD.CLASS.PHP AND SAVE IT TO 
<?php 
if( ! defined( 'ABSPATH' ) ) exit; 
class Cuztom_Field_Ip extends Cuztom_Field 
{ 
var $_supports_repeatable = true; 
var $_supports_bundle = true; 
var $_supports_ajax = true; 
var $css_classes = array( 'cuztom-input', 'cuztom-ip' ); 
function _output( $value ) 
{ 
$output = ''; 
$output .= '<input type="text" ' . $this->output_name() . ' ' . $this->output_id() . ' ' . 
$this->output_css_class() . ' value="' . ( ! empty( $value ) ? $value : '0.0.0.0' ) . '" />'; 
$output .= $this->output_explanation(); 
return $output; 
} 
INC/CUZTOM/CLASSES/FIELDS
CUSTOM FIELD TYPE 
1 CREATE YOURFIELD.CLASS.PHP AND SAVE IT TO 
function save_value( $value ) { 
return filter_var( $value, FILTER_VALIDATE_IP ) ? $value : '0.0.0.0'; 
} 
} 
INC/CUZTOM/CLASSES/FIELDS
CUSTOM FIELD TYPE 
2 INCLUDE FIELD TYPE CLASS 
private function includes() 
{ 
/*...*/ 
include( CUZTOM_DIR . 'classes/fields/ip.class.php' ); 
}
CONTRIBUTE ON GITHUB 
https://github.com/gizburdt/wp-cuztom
THANK 
YOU! 
_ Ante Primorac (@anteprimorac) 
_ Web Developer @ Slicejack 
_ 2nd WordPress Meetup Split

Más contenido relacionado

La actualidad más candente

Introduction to Moose
Introduction to MooseIntroduction to Moose
Introduction to Moosethashaa
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackVic Metcalfe
 
Moose - YAPC::NA 2012
Moose - YAPC::NA 2012Moose - YAPC::NA 2012
Moose - YAPC::NA 2012xSawyer
 
OO Perl with Moose
OO Perl with MooseOO Perl with Moose
OO Perl with MooseNelo Onyiah
 
Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Jeff Carouth
 
WordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPressWordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPressAlena Holligan
 
An (Inaccurate) Introduction to Python
An (Inaccurate) Introduction to PythonAn (Inaccurate) Introduction to Python
An (Inaccurate) Introduction to PythonNicholas Tollervey
 
My sql presentation
My sql presentationMy sql presentation
My sql presentationNikhil Jain
 
Introduction To Moose
Introduction To MooseIntroduction To Moose
Introduction To MooseMike Whitaker
 
Taking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order FunctionsTaking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order FunctionsDavid Golden
 
Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma IntroduçãoÍgor Bonadio
 
(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and ProfitOlaf Alders
 
Mkscript sh
Mkscript shMkscript sh
Mkscript shBen Pope
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Kris Wallsmith
 
performance vamos dormir mais?
performance vamos dormir mais?performance vamos dormir mais?
performance vamos dormir mais?tdc-globalcode
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎anzhong70
 

La actualidad más candente (20)

Introduction to Moose
Introduction to MooseIntroduction to Moose
Introduction to Moose
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: Hack
 
Moose - YAPC::NA 2012
Moose - YAPC::NA 2012Moose - YAPC::NA 2012
Moose - YAPC::NA 2012
 
OO Perl with Moose
OO Perl with MooseOO Perl with Moose
OO Perl with Moose
 
Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4
 
WordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPressWordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPress
 
An (Inaccurate) Introduction to Python
An (Inaccurate) Introduction to PythonAn (Inaccurate) Introduction to Python
An (Inaccurate) Introduction to Python
 
Wsomdp
WsomdpWsomdp
Wsomdp
 
My sql presentation
My sql presentationMy sql presentation
My sql presentation
 
Introduction To Moose
Introduction To MooseIntroduction To Moose
Introduction To Moose
 
Taking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order FunctionsTaking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order Functions
 
Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma Introdução
 
Smelling your code
Smelling your codeSmelling your code
Smelling your code
 
(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit
 
Mkscript sh
Mkscript shMkscript sh
Mkscript sh
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
 
PHP Tutorial (funtion)
PHP Tutorial (funtion)PHP Tutorial (funtion)
PHP Tutorial (funtion)
 
performance vamos dormir mais?
performance vamos dormir mais?performance vamos dormir mais?
performance vamos dormir mais?
 
PHP 1
PHP 1PHP 1
PHP 1
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎
 

Similar a WordPress Cuztom Helper

Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress sitereferences
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018Adam Tomat
 
Dig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoDig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoMohamed Mosaad
 
Propel sfugmd
Propel sfugmdPropel sfugmd
Propel sfugmdiKlaus
 
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...allilevine
 
Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsPierre MARTIN
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentTammy Hart
 
Open Source Search: An Analysis
Open Source Search: An AnalysisOpen Source Search: An Analysis
Open Source Search: An AnalysisJustin Finkelstein
 
WordPress as an application framework
WordPress as an application frameworkWordPress as an application framework
WordPress as an application frameworkDustin Filippini
 
Speed Things Up with Transients
Speed Things Up with TransientsSpeed Things Up with Transients
Speed Things Up with TransientsCliff Seal
 
Building Your First Widget
Building Your First WidgetBuilding Your First Widget
Building Your First WidgetChris Wilcoxson
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress WebsitesKyle Cearley
 
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011camp_drupal_ua
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)Night Sailer
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of LithiumNate Abele
 
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014Cliff Seal
 

Similar a WordPress Cuztom Helper (20)

Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018
 
Dig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoDig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup Cairo
 
Propel sfugmd
Propel sfugmdPropel sfugmd
Propel sfugmd
 
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
 
Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP Applications
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme development
 
Open Source Search: An Analysis
Open Source Search: An AnalysisOpen Source Search: An Analysis
Open Source Search: An Analysis
 
WordPress as an application framework
WordPress as an application frameworkWordPress as an application framework
WordPress as an application framework
 
Speed Things Up with Transients
Speed Things Up with TransientsSpeed Things Up with Transients
Speed Things Up with Transients
 
Quality code by design
Quality code by designQuality code by design
Quality code by design
 
Building Your First Widget
Building Your First WidgetBuilding Your First Widget
Building Your First Widget
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
 
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
 
Lettering js
Lettering jsLettering js
Lettering js
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
 
Intermediate PHP
Intermediate PHPIntermediate PHP
Intermediate PHP
 

Último

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Último (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

WordPress Cuztom Helper

  • 1. WORDPRESS CUZTOM HELPER - A helper to make the life of Wordpress developers easier. _ Ante Primorac (@anteprimorac) _ Web Developer @ Slicejack _ 2nd WordPress Meetup Split
  • 2. WHAT DO WE USE CUZTOM FOR? _ Post types _ Taxonomies _ Meta Boxes _ Post meta _ Term meta _ User meta
  • 3. HOW TO USE CUZTOM? 1 CLONE REPOSITORY TO INC/CUZTOM/ slicejack:inc ante$ git clone https://github.com/gizburdt/wp-cuztom.git cuztom 2 CREATE CUZTOM.PHP AND LET THE MAGIC BEGIN <?php define( 'CUZTOM_TEXTDOMAIN', 'slicejack' ); define( 'CUZTOM_URL', get_template_directory_uri() . '/inc/cuztom' ); require( 'cuztom/cuztom.php' );
  • 4. BOOKS LIBRARY 1 CREATE CUSTOM POST TYPE - BOOK $books = new Cuztom_Post_Type( 'book', array( 'has_archive' => true, 'rewrite' => array( 'slug' => 'books' ), 'supports' => array( 'title', 'editor', 'thumbnail', 'revisions' ) ) );
  • 5.
  • 6. BOOKS LIBRARY 2 CREATE CUSTOM TAXONOMY - BOOK CATEGORY $book_category = new Cuztom_Taxonomy( 'Book Category', 'book' );
  • 7.
  • 8. BOOKS LIBRARY 3 CREATE METABOX - INFO $books->add_meta_box( 'info', 'Info', array( array( 'name' => 'author', 'label' => 'Author', 'type' => 'text' ), array( 'name' => 'date', 'label' => 'Date', 'type' => 'date' ), array( 'name' => 'price', 'label' => 'Price', 'type' => 'text' ), array( 'name' => 'number_of_pages', 'label' => 'Number of pages', 'type' => 'text' ), array( 'name' => 'bind_type', 'label' => 'Bind type', 'type' => 'select', 'options' => array( 'hardcover' => 'Hardcover', 'double-wire' => 'Double wire', 'spiral' => 'Spiral' ), 'default_value' => 'hardcover' ), array( 'name' => 'size', 'label' => 'Size', 'type' => 'select', 'options' => array( 'a5' => 'A5', 'a4' => 'A4', 'a3' => 'A3' ), 'default_value' => 'a4' ) ) );
  • 9. FIELD TYPES _ text - a simple text field _ textarea - a large textarea for multiple lines of text _ checkbox - a simple boolean entry _ yesno - allows choice of yes/no (pre-made extension of radio) _ select - combo box selection _ multi_select - multi select selection _ checkboxes - a checkbox group _ radios - a radio group _ wysiwyg - an editor with the same controls as the standard WordPress editor _ image - image upload box _ file - file upload box _ date - date selection _ datetime - date and time (hour+minutes) selection _ time - time (hour+minutes) selection _ color - color selection _ post_select - allows inner-post references via a combo-box _ post_checkboxes - allows inner-post references via a checkbox group _ term_select - allows category references via a combo-box _ term_checkboxes - allows category references via a checkbox group _ hidden - a hidden field (oſten used to store information not visible to the user).
  • 10.
  • 11. BOOKS LIBRARY 4 TEMPLATE <div class="entry-content"> <?php $bind_types = array( 'hardcover' => __( 'Hardcover', 'slicejack' ), 'double-wire' => __( 'Double wire', 'slicejack' ), 'spiral' => __( 'Spiral', 'slicejack' ) ); $sizes = array( 'a5' => __( 'A5', 'slicejack' ), 'a4' => __( 'A4', 'slicejack' ), 'a3' => __( 'A3', 'slicejack' ) ); ?> <strong><?php _e( 'Author:', 'slicejack' ); ?></strong> <?php echo get_post_meta( get_the_id(), '_info_author', true ); ?><br /> <strong><?php _e( 'Date:', 'slicejack' ); ?></strong> <?php echo date( 'd.m.Y.', get_post_meta( get_the_id(), '_info_date', true ) ); ?><br /> <strong><?php _e( 'Price:', 'slicejack' ); ?></strong> $<?php echo get_post_meta( get_the_id(), '_info_price', true ); ?><br /> <strong><?php _e( 'Number of pages:', 'slicejack' ); ?></strong> <?php echo get_post_meta( get_the_id(), '_info_number_of_pages', true ); ?><br /> <strong><?php _e( 'Bind type:', 'slicejack' ); ?></strong> <?php echo $bind_types[ get_post_meta( get_the_id(), '_info_bind_type', true ) ]; ?><br /> <strong><?php _e( 'Size:', 'slicejack' ); ?></strong> <?php echo $sizes[ get_post_meta( get_the_id(), '_info_size', true ) ]; ?> </div><!-- .entry-content -->
  • 12.
  • 13. FEATURED LIBRARY 1 ADD METABOX TO PAGE TEMPLATE if ( is_admin() ) : $pid = 0; if( array_key_exists( 'post', $_GET ) ) $pid = $_GET['post']; elseif ( array_key_exists( 'post_ID', $_POST ) ) $pid = $_POST['post_ID']; $page_template = basename( get_post_meta( $pid, '_wp_page_template', true ) ); if ( 'featured-library.php' == $page_template ) : $cpage = new Cuztom_Post_Type( 'page' ); $cpage ->remove_post_type_support( array( 'editor', 'thumbnail' ) ) ->add_meta_box( 'library', 'Library', array( 'bundle', array( array( 'name' => 'book', 'label' => 'Book', 'type' => 'post_select', 'args' => array( 'post_type' => 'book', 'show_option_none' => 'None' ) )
  • 14. FEATURED LIBRARY 2 PAGE TEMPLATE <?php // Start the Loop. while ( have_posts() ) : the_post(); ?> <?php the_title( '<header class="entry-header"><h1 class="entry-title">', '</h1></ header><!-- .entry-header -->' ); ?> <?php $library = get_post_meta( get_the_id(), '_library', true ); foreach( $library as $book ) : $post = get_post( $book['_book'] ); setup_postdata( $post ); get_template_part( 'book' ); endforeach; wp_reset_postdata(); endwhile; ?>
  • 15. CUSTOM FIELD TYPE 1 CREATE YOURFIELD.CLASS.PHP AND SAVE IT TO <?php if( ! defined( 'ABSPATH' ) ) exit; class Cuztom_Field_Ip extends Cuztom_Field { var $_supports_repeatable = true; var $_supports_bundle = true; var $_supports_ajax = true; var $css_classes = array( 'cuztom-input', 'cuztom-ip' ); function _output( $value ) { $output = ''; $output .= '<input type="text" ' . $this->output_name() . ' ' . $this->output_id() . ' ' . $this->output_css_class() . ' value="' . ( ! empty( $value ) ? $value : '0.0.0.0' ) . '" />'; $output .= $this->output_explanation(); return $output; } INC/CUZTOM/CLASSES/FIELDS
  • 16. CUSTOM FIELD TYPE 1 CREATE YOURFIELD.CLASS.PHP AND SAVE IT TO function save_value( $value ) { return filter_var( $value, FILTER_VALIDATE_IP ) ? $value : '0.0.0.0'; } } INC/CUZTOM/CLASSES/FIELDS
  • 17. CUSTOM FIELD TYPE 2 INCLUDE FIELD TYPE CLASS private function includes() { /*...*/ include( CUZTOM_DIR . 'classes/fields/ip.class.php' ); }
  • 18. CONTRIBUTE ON GITHUB https://github.com/gizburdt/wp-cuztom
  • 19. THANK YOU! _ Ante Primorac (@anteprimorac) _ Web Developer @ Slicejack _ 2nd WordPress Meetup Split