SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
Short Codes
           Pain Free Magic


         mike susz, developer
            squaredesign

squaredesign
What is a Short Code?

    • WordPress ShortCode API (since v2.5)

    • we CAN do clever things inside Post Content

    • three parts to make a Short Code




             let’s start with an example!
squaredesign          short codes: pain free magic
Part #1: the [shortcode]
    Upload/Insert




    Hi everyone!

    i hope you’re having a super [year]!


    © [year] squaredesign, all rights reserved



           next up: the PHP function...
squaredesign        short codes: pain free magic
Part #2: the PHP function
  Theme Functions (functions.php)
  <?php

   function getTheYear() {
     return date(‘Y’);
   }



  ?>
                hook them together...
squaredesign         short codes: pain free magic
Part #3: the hookup
  Theme Functions (functions.php)
  <?php

   function getTheYear() {
     return date(‘Y’);
   }
  add_shortcode(‘year’,‘getTheYear’);

  ?>
                  and the results...
squaredesign         short codes: pain free magic
The Results!

             Just another WordPress weblog




      let’s solve another practical problem...
squaredesign           short codes: pain free magic
a design problem
               looks quite a bit like Kubrick




                possible solutions...
squaredesign           short codes: pain free magic
Possible Solutions:

    • Make it an image (yuck)
    • style a <blockquote>
    • teach the client HTML
    • give up




         let’s use a Short Code - [pullquote]
squaredesign         short codes: pain free magic
An opening/closing Short Code
    Upload/Insert



    Excepteur sint occaecat cupidatat non proident,
    sunt in culpa qui officia deserunt mollit anim id
    est laborum.

    [pullquote]velit esse cillum dolore eu fugiat nulla
    sint non culpa[/pullquote] Lorem ipsum dolor sit
    amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna
    aliqua.Ut enim ad minim veniam, quis nostrud...


         and the PHP to make it happen...
squaredesign       short codes: pain free magic
PHP for opening/closing Short Code
  Theme Functions (functions.php)
   <?php
   add_shortcode('pullquote','makePullQuote');

   function makePullQuote($attributes, $contents) {
   	 return '<div class="pullquote">' .
   	 $contents .
   	 "</div>";
   }

   ?>
           add content to the output...
squaredesign       short codes: pain free magic
PHP for opening/closing Short Code
  Theme Functions (functions.php)
  <?php
  add_shortcode('pullquote','makePullQuote');

  function makePullQuote($attributes, $contents) {
  	 return "<div class=" pullquote ">" .
  	 $contents .
  	 "</div>";
  }

  ?>
                     the result...
squaredesign         short codes: pain free magic
The Results!

               looks quite a bit like Kubrick




                                          <div class="pullquote">
                                            velit esse cillum
                                            dolore eu fugiat
                                            nulla sint non culpa
                                          </div>




squaredesign           short codes: pain free magic
Revisions!




         we’ll use Short Code Attributes
squaredesign       short codes: pain free magic
Short Code with Attributes
    Upload/Insert




    [pullquote side='left']sunt in culpa qui officia
    deserunt[/pullquote]Lorem ipsum dolor sit amet,
    consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna
    aliqua...

    [pullquote side='right']velit esse cillum dolore eu
    fugiat nulla sint non culpa[/pullquote]Lorem
    ipsum dolor sit amet.Ut enim ad minim veniam...

        our PHP code gets the Attributes...
squaredesign       short codes: pain free magic
the PHP function, using Attributes
  Theme Functions (functions.php)
   <?php
   add_shortcode('pullquote','makePullQuote');
   function makePullQuote($attributes, $contents) {
   	 $align = $attributes[‘side’];
   	 return “<div class=" pullquote $align ">” .
   	 $contents .
   	 "</div>";
   }

   ?>
      let’s do something with the Attributes...
squaredesign         short codes: pain free magic
the PHP function, using Attributes
  Theme Functions (functions.php)
  <?php
   add_shortcode('pullquote','makePullQuote');
   function makePullQuote($attributes, $contents) {
   	 $align = $attributes[‘side’];
   	 return “<div class=" pullquote $align ">” .
   	 $contents .
   	 "</div>";
   }

  ?>
            now one left, one right...
squaredesign      short codes: pain free magic
The Results!
     <div class="pullquote left">
       sunt in culpa qui officia
       deserunt   looks quite a bit like Kubrick
     </div>



                                 <div class="pullquote right">
                                   velit esse cillum dolore eu
                                   fugiat nulla sint non culpa
                                 </div>




squaredesign                short codes: pain free magic
With Short Codes we can:
   inject [stuff] into Post Content

   manipulate [parts] of Post Content [/parts]

   solve real problems

   empower users!



             are there Plugins available?
squaredesign          short codes: pain free magic
WordPress Plugin Directory
   • Embed RSS feed
   • Amazon WishList
   • Paypal Donations
   • Easy Contact Form
   • tag cloud
   • sitemap
   • delicious
   • weather
   • etc.

        can i stop talking so quickly, now?
squaredesign        short codes: pain free magic
For more information:
         squaredesign.com/shortcodes
               @squaredesign




                 Thank You!   ☺
squaredesign      short codes: pain free magic

Contenu connexe

Similaire à Short Codes: Pain Free Magic

How to develop frontend quiz app using vue js
How to develop frontend quiz app using vue jsHow to develop frontend quiz app using vue js
How to develop frontend quiz app using vue jsKaty Slemon
 
Creating Content With Shortcodes
Creating Content With ShortcodesCreating Content With Shortcodes
Creating Content With ShortcodesJon Bishop
 
WordPress and Shortcodes
WordPress and ShortcodesWordPress and Shortcodes
WordPress and ShortcodesJon Bishop
 
Сергей Больщиков "Protractor Tips & Tricks"
Сергей Больщиков "Protractor Tips & Tricks"Сергей Больщиков "Protractor Tips & Tricks"
Сергей Больщиков "Protractor Tips & Tricks"Fwdays
 
Features, Exportables & You
Features, Exportables & YouFeatures, Exportables & You
Features, Exportables & Youjskulski
 
Dsug 05 02-15 - ScalDI - lightweight DI in Scala
Dsug 05 02-15 - ScalDI - lightweight DI in ScalaDsug 05 02-15 - ScalDI - lightweight DI in Scala
Dsug 05 02-15 - ScalDI - lightweight DI in ScalaUgo Matrangolo
 
Modular Web Applications With Netzke
Modular Web Applications With NetzkeModular Web Applications With Netzke
Modular Web Applications With Netzkenetzke
 
Yeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsYeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsclimboid
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and SymfonyIgnacio Martín
 
Learn to build a CodeIgniter Login and Registration with source code.pdf
Learn to build a CodeIgniter Login and Registration with source code.pdfLearn to build a CodeIgniter Login and Registration with source code.pdf
Learn to build a CodeIgniter Login and Registration with source code.pdfBe Problem Solver
 
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeRakesh Kushwaha
 
Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)Damien Carbery
 
Sum of the Parts Speaker Series - Experience Engineering and UX
Sum of the Parts Speaker Series - Experience Engineering and UXSum of the Parts Speaker Series - Experience Engineering and UX
Sum of the Parts Speaker Series - Experience Engineering and UXvincebohner
 
Reaching for the Future with Web Components and Polymer
Reaching for the Future with Web Components and PolymerReaching for the Future with Web Components and Polymer
Reaching for the Future with Web Components and PolymerFITC
 
Agile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai ShevchenkoAgile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai ShevchenkoMoldova ICT Summit
 
JQUERY TUTORIALS
JQUERY TUTORIALSJQUERY TUTORIALS
JQUERY TUTORIALSMoize Roxas
 
From Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) AgainFrom Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) Againjonknapp
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScriptJeremy Likness
 
Presentation
PresentationPresentation
PresentationTestled
 

Similaire à Short Codes: Pain Free Magic (20)

How to develop frontend quiz app using vue js
How to develop frontend quiz app using vue jsHow to develop frontend quiz app using vue js
How to develop frontend quiz app using vue js
 
Creating Content With Shortcodes
Creating Content With ShortcodesCreating Content With Shortcodes
Creating Content With Shortcodes
 
WordPress and Shortcodes
WordPress and ShortcodesWordPress and Shortcodes
WordPress and Shortcodes
 
Сергей Больщиков "Protractor Tips & Tricks"
Сергей Больщиков "Protractor Tips & Tricks"Сергей Больщиков "Protractor Tips & Tricks"
Сергей Больщиков "Protractor Tips & Tricks"
 
Features, Exportables & You
Features, Exportables & YouFeatures, Exportables & You
Features, Exportables & You
 
Dsug 05 02-15 - ScalDI - lightweight DI in Scala
Dsug 05 02-15 - ScalDI - lightweight DI in ScalaDsug 05 02-15 - ScalDI - lightweight DI in Scala
Dsug 05 02-15 - ScalDI - lightweight DI in Scala
 
Modular Web Applications With Netzke
Modular Web Applications With NetzkeModular Web Applications With Netzke
Modular Web Applications With Netzke
 
Yeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsYeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web apps
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
 
Learn to build a CodeIgniter Login and Registration with source code.pdf
Learn to build a CodeIgniter Login and Registration with source code.pdfLearn to build a CodeIgniter Login and Registration with source code.pdf
Learn to build a CodeIgniter Login and Registration with source code.pdf
 
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcode
 
Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)
 
Sum of the Parts Speaker Series - Experience Engineering and UX
Sum of the Parts Speaker Series - Experience Engineering and UXSum of the Parts Speaker Series - Experience Engineering and UX
Sum of the Parts Speaker Series - Experience Engineering and UX
 
Reaching for the Future with Web Components and Polymer
Reaching for the Future with Web Components and PolymerReaching for the Future with Web Components and Polymer
Reaching for the Future with Web Components and Polymer
 
Agile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai ShevchenkoAgile methodologies based on BDD and CI by Nikolai Shevchenko
Agile methodologies based on BDD and CI by Nikolai Shevchenko
 
JQUERY TUTORIALS
JQUERY TUTORIALSJQUERY TUTORIALS
JQUERY TUTORIALS
 
Coding Naked 2023
Coding Naked 2023Coding Naked 2023
Coding Naked 2023
 
From Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) AgainFrom Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) Again
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Presentation
PresentationPresentation
Presentation
 

Dernier

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
[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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Dernier (20)

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
[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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Short Codes: Pain Free Magic

  • 1. Short Codes Pain Free Magic mike susz, developer squaredesign squaredesign
  • 2. What is a Short Code? • WordPress ShortCode API (since v2.5) • we CAN do clever things inside Post Content • three parts to make a Short Code let’s start with an example! squaredesign short codes: pain free magic
  • 3. Part #1: the [shortcode] Upload/Insert Hi everyone! i hope you’re having a super [year]! © [year] squaredesign, all rights reserved next up: the PHP function... squaredesign short codes: pain free magic
  • 4. Part #2: the PHP function Theme Functions (functions.php) <?php function getTheYear() { return date(‘Y’); } ?> hook them together... squaredesign short codes: pain free magic
  • 5. Part #3: the hookup Theme Functions (functions.php) <?php function getTheYear() { return date(‘Y’); } add_shortcode(‘year’,‘getTheYear’); ?> and the results... squaredesign short codes: pain free magic
  • 6. The Results! Just another WordPress weblog let’s solve another practical problem... squaredesign short codes: pain free magic
  • 7. a design problem looks quite a bit like Kubrick possible solutions... squaredesign short codes: pain free magic
  • 8. Possible Solutions: • Make it an image (yuck) • style a <blockquote> • teach the client HTML • give up let’s use a Short Code - [pullquote] squaredesign short codes: pain free magic
  • 9. An opening/closing Short Code Upload/Insert Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. [pullquote]velit esse cillum dolore eu fugiat nulla sint non culpa[/pullquote] Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Ut enim ad minim veniam, quis nostrud... and the PHP to make it happen... squaredesign short codes: pain free magic
  • 10. PHP for opening/closing Short Code Theme Functions (functions.php) <?php add_shortcode('pullquote','makePullQuote'); function makePullQuote($attributes, $contents) { return '<div class="pullquote">' . $contents . "</div>"; } ?> add content to the output... squaredesign short codes: pain free magic
  • 11. PHP for opening/closing Short Code Theme Functions (functions.php) <?php add_shortcode('pullquote','makePullQuote'); function makePullQuote($attributes, $contents) { return "<div class=" pullquote ">" . $contents . "</div>"; } ?> the result... squaredesign short codes: pain free magic
  • 12. The Results! looks quite a bit like Kubrick <div class="pullquote"> velit esse cillum dolore eu fugiat nulla sint non culpa </div> squaredesign short codes: pain free magic
  • 13. Revisions! we’ll use Short Code Attributes squaredesign short codes: pain free magic
  • 14. Short Code with Attributes Upload/Insert [pullquote side='left']sunt in culpa qui officia deserunt[/pullquote]Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua... [pullquote side='right']velit esse cillum dolore eu fugiat nulla sint non culpa[/pullquote]Lorem ipsum dolor sit amet.Ut enim ad minim veniam... our PHP code gets the Attributes... squaredesign short codes: pain free magic
  • 15. the PHP function, using Attributes Theme Functions (functions.php) <?php add_shortcode('pullquote','makePullQuote'); function makePullQuote($attributes, $contents) { $align = $attributes[‘side’]; return “<div class=" pullquote $align ">” . $contents . "</div>"; } ?> let’s do something with the Attributes... squaredesign short codes: pain free magic
  • 16. the PHP function, using Attributes Theme Functions (functions.php) <?php add_shortcode('pullquote','makePullQuote'); function makePullQuote($attributes, $contents) { $align = $attributes[‘side’]; return “<div class=" pullquote $align ">” . $contents . "</div>"; } ?> now one left, one right... squaredesign short codes: pain free magic
  • 17. The Results! <div class="pullquote left"> sunt in culpa qui officia deserunt looks quite a bit like Kubrick </div> <div class="pullquote right"> velit esse cillum dolore eu fugiat nulla sint non culpa </div> squaredesign short codes: pain free magic
  • 18. With Short Codes we can: inject [stuff] into Post Content manipulate [parts] of Post Content [/parts] solve real problems empower users! are there Plugins available? squaredesign short codes: pain free magic
  • 19. WordPress Plugin Directory • Embed RSS feed • Amazon WishList • Paypal Donations • Easy Contact Form • tag cloud • sitemap • delicious • weather • etc. can i stop talking so quickly, now? squaredesign short codes: pain free magic
  • 20. For more information: squaredesign.com/shortcodes @squaredesign Thank You! ☺ squaredesign short codes: pain free magic