GithubHelp home page GithubHelp logo

raucher / squeeze Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dwsupplee/squeeze

0.0 2.0 0.0 939 KB

A PHP 5.3 WordPress Plugin Development MVC Framework

Home Page: http://jdpedrie.github.io/squeeze/

License: MIT License

squeeze's Introduction

SQUEEZE Plugin Framework

Rapid WordPress plugin development using modern techniques and principles. I was tired of writing WordPress plugins that sucked. So I started writing Squeeze. Squeeze provides an MVC structure for plugin development, utilizing modern principles such as namespacing and autoloading, parameterized queries, object oriented data management and API access and more.

Squeeze is meant for software engineers. But more than that, Squeeze is meant for anyone who wants to rapidly develop maintainable, standards-based plugins for the most popular platform on earth.

If you've ever taken a freelance job working on a WordPress project, you may find Squeeze useful.

If you find this useful please let me know. If you've got a question, please let me know. If you want to contribute, I'd be stoked.

Developing An App

Squeeze functions as an external dependency that lives in your wp-content/plugins directory. For an example of how Squeeze is implemented as a development framework, check out the squeezeExample WordPress Plugin.

Features

  • Create custom settings/options pages
  • Custom Post Type Support
  • Custom Meta Boxes on Custom and Core post types.
  • Manage Users (Insert, Update, Delete, Set Roles)
  • Manage Posts (Insert, Update, Delete, Trash)
  • Manage Comments (Insert, Update, Delete, Trash)
  • Manage WordPress Options in an object-oriented fashion.
  • Fetch and Save User Metadata
  • Add columns to the User List
  • Represents data in an object-oriented fashion
  • PDO wrapper for parameterized queries
  • MVC structure

Examples

  • Create an Admin Page

    cd SqueezeExample/App/Controller
    touch MyAdminPage.php
    
    <?php
    
    namespace SqueezeExample\App\Controller;
    
    class MyAdminPage extends \Squeeze1_0\Core\Mvc\AdminPageController
    {
      protected $page_title = 'My Admin Page';
      protected $capability = 'manage_options';
    
      public function __construct()
      {
        parent::__construct();
      }
    
      public function index()
      {
        echo "Hello World!";
      }
    
    }
    
  • Create an Admin Dashboard Widget

    cd SqueezeExample/App/Controller
    touch MyDashboardWidget.php
    
    <?php
    
    namespace Squeeze\App\Controller;
    
    class MyDashboardWidget extends \Squeeze1_0\Core\Mvc\DashboardWidget
    {
      protected $title = 'Squeezed Widget';
    
      public function index()
      {
        echo "Hello World!";
      }
    }
    
  • Change a Post Title and increment the value of a meta field

    <?php
    
    $post_ID = 1;
    $myPost = new \Squeeze1_0\Api\Post($post_ID);
    $myPost->set('post_title', 'Hello World');
    $meta_value = $myPost->get('number_of_views');
    $myPost->set('number_of_views', $meta_value++);
    $myPost->save();
    
  • Create a custom MySQL Query

    <?php
    $PDO = \Squeeze1_0\Db\PDO::instance();
    $query = $PDO->query('SELECT * FROM wp_posts LIMIT 1');
    
    $post = $query->fetch();
    echo $post->post_title();
    

A word on style

I've consciously chosen to adhere* to PSR-2 over the WordPress code style guide. For one thing, PSR is a more widely accepted and interoperable standard. I'm making extensive use of the PSR-style autoloader, and Squeeze is built to easily integrate any PSR-compatible Composer module. PSR is a professional standard that is used by a larger percentage of the PHP community. And finally, while none of this should be taken to imply that I believe there is anything wrong with the WordPress style guide, I simply prefer and am used to using the PSR standard.

At the end of the day, the most important thing isn't which style you choose to follow, or even that you're completely implementing one or another, the important thing is that you choose a coding style and implement it uniformly throughout a project.

(* The notable exception is my use of two spaces rather than the four specified in PSR. It's a carryover from my language du jour, Javascript, and it's purely a personal preference.)

Authors

Squeeze is written by me, John Dennis Pedrie. Thanks to David Supplee for code reviews and useful suggestions.

License

Squeeze is licensed under the MIT License. A copy of the MIT License may be found in the repository under LICENSE.md.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.