|
| 1 | +# creative-workflow/lib-wordpress |
| 2 | + |
| 3 | +### Setup |
| 4 | +``` |
| 5 | +git submodule add https://github.com/creative-workflow/lib-wp.git ./wordpress/wp-content/themes/child/lib/cw/wp |
| 6 | +git submodule add https://github.com/creative-workflow/lib-php.git ./wordpress/wp-content/themes/child/lib/cw/php |
| 7 | +git submodule add https://github.com/creative-workflow/lib-sass.git ./wordpress/wp-content/themes/child/lib/cw/sass |
| 8 | +``` |
| 9 | + |
| 10 | +### functions.php |
| 11 | +```php |
| 12 | +<?php |
| 13 | + |
| 14 | +define('CW_LIB_FOLDER', __DIR__ . '/lib'); |
| 15 | +define('CW_DIVI_MODULES_FOLDER', __DIR__ . '/modules'); |
| 16 | +define('CW_WP_SHORTCODES_FOLDER', __DIR__ . '/shortcodes'); |
| 17 | + |
| 18 | +foreach(glob(__DIR__ . '/initializers/*.php') as $file) |
| 19 | + require $file; |
| 20 | + |
| 21 | +``` |
| 22 | + |
| 23 | +### initializers/ |
| 24 | +##### 01_autoload.php |
| 25 | +```php |
| 26 | +<?php |
| 27 | + |
| 28 | +require CW_LIB_FOLDER.'/cw/php/core/Autoloader.php'; |
| 29 | + |
| 30 | +cw\php\core\Autoloader::registerNamespaceLoader( |
| 31 | + CW_LIB_FOLDER, |
| 32 | + CW_DIVI_MODULES_FOLDER |
| 33 | + ); |
| 34 | + |
| 35 | + |
| 36 | +``` |
| 37 | + |
| 38 | +##### 03_options.php |
| 39 | +```php |
| 40 | +<?php |
| 41 | + |
| 42 | +global $wpOptions; |
| 43 | + |
| 44 | +$wpOptions = new \cw\wp\admin\Options('child_options'); |
| 45 | + |
| 46 | +$wpOptions->adminBarName('Page-Options') |
| 47 | + ->typeText('global_footer_post_id', |
| 48 | + 'ID des Footer-Posts (Divi-Bibliothek)') |
| 49 | + |
| 50 | + ->typePlain('color_info', |
| 51 | + 'Farbinfo', |
| 52 | + '<div class="theme-color green"> |
| 53 | + <div class="color-monitor" style="background-color: #72ac4d"></div> |
| 54 | + <b>hex:</b> #72ac4d <br> |
| 55 | + <b>rgb:</b> rgba(114, 172, 77, 1) |
| 56 | + </div>'); |
| 57 | + |
| 58 | +``` |
| 59 | + |
| 60 | +##### 04_assets.php |
| 61 | +```php |
| 62 | +<?php |
| 63 | + |
| 64 | +global $wpOptions, $jQuery, $wpAssets; |
| 65 | + |
| 66 | +$jQuery = \cw\php\js\jQuery::getInstance(); |
| 67 | +$wpAssets = \cw\wp\Assets::getInstance(); |
| 68 | + |
| 69 | +$wpAssets->scripts() |
| 70 | + ->add('main-js', 'js/main.js', ['jquery'], 1, true) |
| 71 | + ->inline('main-js', $wpOptions->toJs()) |
| 72 | + ->jqReady( |
| 73 | + $jQuery->getScript( |
| 74 | + $wpAssets->expand('js/app/loader.js') |
| 75 | + ) |
| 76 | + ) |
| 77 | + ->replaceJquery('//ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js') |
| 78 | + ->removeEmojiScript() |
| 79 | + ->remove( |
| 80 | + 'google-maps-api', |
| 81 | + 'divi-fitvids', |
| 82 | + 'waypoints', |
| 83 | + 'magnific-popup', |
| 84 | + 'hashchange', |
| 85 | + 'salvattore', |
| 86 | + 'easypiechart', |
| 87 | + 'magnific-popup', |
| 88 | + 'wp-embed' |
| 89 | + ); |
| 90 | + |
| 91 | + |
| 92 | +$wpAssets->styles() |
| 93 | + ->addParent() |
| 94 | + ->addAdmin('eve-admin-css', 'admin.css') |
| 95 | + ->conditional(function($wpAssests){ |
| 96 | + if(!current_user_can( 'update_core' )) // no admin |
| 97 | + $wpAssests->remove('dashicons'); |
| 98 | + }); |
| 99 | + |
| 100 | +$wpAssets->theme() |
| 101 | + ->touchAfterPostUpdated() // can be used for browser-sync reload |
| 102 | + ->addFooterContent($jQuery); // when will render onReady content when __toString is called |
| 103 | + |
| 104 | +``` |
| 105 | + |
| 106 | +##### 06_menu.php |
| 107 | +```php |
| 108 | +<?php |
| 109 | +$childMenu = new \cw\wp\Menus(); |
| 110 | + |
| 111 | +$childMenu->addMenu('footer-1-menu') |
| 112 | + ->addMenu('footer-2-menu') |
| 113 | + ->addMenu('footer-3-menu'); |
| 114 | +``` |
| 115 | + |
| 116 | +##### 07_custom_post_types.php |
| 117 | +```php |
| 118 | +<?php |
| 119 | + |
| 120 | +$postType = new \cw\wp\custom\PostType('job_post'); |
| 121 | +$postType->typePage() |
| 122 | + ->isPublic() |
| 123 | + ->slug('jobs') |
| 124 | + ->hasArchive(false) |
| 125 | + ->isHierarchical(false) |
| 126 | + ->isPubliclyQueryable() |
| 127 | + ->showInUi() |
| 128 | + ->showInMenu() |
| 129 | + ->supportsTitle() |
| 130 | + ->supportsEditor() |
| 131 | + ->supportsThumbnail() |
| 132 | + ->supportsRevisions() |
| 133 | + ->supportsPageAttributes() |
| 134 | + ->supportsPostFormats() |
| 135 | + ->menuPositionBelowPosts() |
| 136 | + ->name('Job-Board') |
| 137 | + ->singularName('Stellenanzeige') |
| 138 | + ->menuName('Job-Board') |
| 139 | + ->labelAddNew('Anzeige erstellen') |
| 140 | + ->adminBarName('Job-Board') |
| 141 | + ->addMetaBox( |
| 142 | + (new \cw\wp\custom\MetaBox('task')) |
| 143 | + ->title('Aufgaben') |
| 144 | + ->typeHtml() |
| 145 | + ) |
| 146 | + ->publish(); |
| 147 | + |
| 148 | +$taxanomy = new \cw\wp\custom\Taxanomy('job_place'); |
| 149 | +$taxanomy->setObjectType($postType) |
| 150 | + ->isHierarchical(false) |
| 151 | + ->showInUi() |
| 152 | + ->showAdminColumn() |
| 153 | + ->queryVar(true) |
| 154 | + ->slug('place') |
| 155 | + ->name('Standorte') |
| 156 | + ->publish(); |
| 157 | + |
| 158 | +$taxanomy = new \cw\wp\custom\Taxanomy('job_category'); |
| 159 | +$taxanomy->setObjectType($postType) |
| 160 | + ->isHierarchical(false) |
| 161 | + ->showInUi() |
| 162 | + ->showAdminColumn() |
| 163 | + ->queryVar(true) |
| 164 | + ->slug('category') |
| 165 | + ->name('Kategorien') |
| 166 | + ->publish(); |
| 167 | + |
| 168 | +$taxanomy = new \cw\wp\custom\Taxanomy('job_position'); |
| 169 | +$taxanomy->setObjectType($postType) |
| 170 | + ->isHierarchical(false) |
| 171 | + ->showInUi() |
| 172 | + ->showAdminColumn() |
| 173 | + ->queryVar(true) |
| 174 | + ->slug('position') |
| 175 | + ->name('Positionen') |
| 176 | + ->publish(); |
| 177 | +``` |
| 178 | + |
| 179 | +##### hallo-world/css/module.sass |
| 180 | +```sass |
| 181 | +@import "variables" |
| 182 | +
|
| 183 | +@import "mixins/css/css3" |
| 184 | +@import "mixins/css/positioning" |
| 185 | +@import "mixins/helper/helper" |
| 186 | +
|
| 187 | +@import "mixins/grid/mediaqueries" |
| 188 | +@import "mixins/grid/grid" |
| 189 | +
|
| 190 | +@import "mixins/wordpress/divi" |
| 191 | +@import "mixins/wordpress/post" |
| 192 | +
|
| 193 | +
|
| 194 | ++custom-divi-module('cw-module-hallo-world') |
| 195 | + .image |
| 196 | + display: none |
| 197 | + +min-width-sm |
| 198 | + +block |
| 199 | + +absolute |
| 200 | + right: -40px |
| 201 | + bottom: 0 |
| 202 | +
|
| 203 | + .content-wrapper |
| 204 | + [...] |
| 205 | +``` |
0 commit comments