Php helper library.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
core
date
debug
js
view
LICENSE
README.md
bower.json
composer.json

README.md

creative-workflow/lib-php

Setup

bower install --save creative-workflow.php

or

composer require creative-workflow/php

or

git submodule add https://github.com/creative-workflow/lib-php.git ./wordpress/wp-content/themes/child/lib/cw/php

Core

  • Singleton-Trait
  • Autoloader (namespaces or snakecase)
  • ArrayAsObject (properties and array_* methods)
  • ObjectAsArray

js

Do something like this:

<?

$jQuery = \cw\php\js\jQuery::getInstance();

$jQuery->when(
  $jQuery->getScript('...'),
  $jQuery->getScript('...'),
  $jQuery->getScript('...')  
)
->then(
  $jQuery->anonymousFunction([],
    $jQuery->select('a.fancybox')
           ->chain('fancybox()')
           ->chain('animate({opacity: 1})')
           ->stop()
  )
)
->stop();

//output generated js code
echo $jQuery->toJsWrapped();

view/Html

Do something like this:

use \cw\php\view\Html;

$html = Html::getInstance()

echo $html->tag('div', ['class' => 'logo-wrapper'])
          ->append(
            $html->image('...', ['class' => 'logo'])
      );


echo $html->script(
        $jQuery->select('a.fancybox')
               ->chain('fancybox()')
               ->chain('animate({opacity: 1})')
               ->stop()
      );

...

view/html/Tag - Label - Input

Do something like this:

$labelTag = new Label('zip_code');
$labelTag->addContent('Zip-Code: ');

$inputTag = new Input('zip_code');
$inputTag->typeNumber()
         ->setId('zip_code')
         ->setPlaceholder('Your Zip-Code')
         ->setRequired()
         ->setAutoCompleteType('postal-code')
         ->setAndForceMaxLength(5);

return (new Tag())->addClass('row')
                  ->addContent($labelTag)
                  ->addContent($inputTag);