| 1 |
<?php |
| 2 |
|
| 3 |
class SGPMDataConfig |
| 4 |
{ |
| 5 |
public static function init() |
| 6 |
{ |
| 7 |
self::addFilters(); |
| 8 |
self::initTargetData(); |
| 9 |
} |
| 10 |
|
| 11 |
public static function addFilters() |
| 12 |
{ |
| 13 |
SGPMHelper::addFilters(); |
| 14 |
} |
| 15 |
|
| 16 |
public static function initTargetData() |
| 17 |
{ |
| 18 |
global $SGPM_DATA_CONFIG_ARRAY; |
| 19 |
|
| 20 |
$targetElementTypes = array( |
| 21 |
'param' => 'select', |
| 22 |
'operator' => 'select', |
| 23 |
'value' => 'select', |
| 24 |
'post_selected' => 'select', |
| 25 |
'page_selected' => 'select', |
| 26 |
'post_type' => 'select', |
| 27 |
'post_category' => 'select', |
| 28 |
'page_type' => 'select', |
| 29 |
'page_template' => 'select' |
| 30 |
); |
| 31 |
$targetParams = array( |
| 32 |
'Post' => array( |
| 33 |
'post_all' => __('All posts', 'sgpmPopupMaker'), |
| 34 |
'post_selected' => __('Selected posts', 'sgpmPopupMaker'), |
| 35 |
'post_type' => __('Post type', 'sgpmPopupMaker'), |
| 36 |
'post_category' => __('Post category', 'sgpmPopupMaker') |
| 37 |
), |
| 38 |
'Page' => array( |
| 39 |
'page_all' => __('All pages', 'sgpmPopupMaker'), |
| 40 |
'page_selected' => __('Selected pages', 'sgpmPopupMaker'), |
| 41 |
'page_type' => __('Page type', 'sgpmPopupMaker'), |
| 42 |
'page_template' => __('Page template', 'sgpmPopupMaker') |
| 43 |
) |
| 44 |
); |
| 45 |
$targetOperators = array( |
| 46 |
array( |
| 47 |
'operator' => 'add', |
| 48 |
'name' => __('<i class="sgpm-margin-top-4 dashicons dashicons-plus"></i>', 'sgpmPopupMaker') |
| 49 |
), |
| 50 |
array( |
| 51 |
'operator' => 'delete', |
| 52 |
'name' => __('<i class="sgpm-margin-top-4 dashicons dashicons-minus"></i>', 'sgpmPopupMaker') |
| 53 |
) |
| 54 |
); |
| 55 |
$targetDataOperator = array( |
| 56 |
'==' => __('Is', 'sgpmPopupMaker'), |
| 57 |
'!=' => __('Is not', 'sgpmPopupMaker') |
| 58 |
); |
| 59 |
$targetInitialData = array( |
| 60 |
array( |
| 61 |
'param' => 'post_all', |
| 62 |
'operator' => '==', |
| 63 |
'value' => '' |
| 64 |
), |
| 65 |
array( |
| 66 |
'param' => 'page_all', |
| 67 |
'operator' => '==', |
| 68 |
'value' => '' |
| 69 |
) |
| 70 |
); |
| 71 |
|
| 72 |
$targetDataParams['param'] = apply_filters('sgpmPopupTargetParams', $targetParams); |
| 73 |
$targetDataParams['operator'] = apply_filters('sgpmPopupTargetOperator', $targetDataOperator); |
| 74 |
$targetDataParams['post_selected'] = apply_filters('sgpmPopupTargetPostData', array()); |
| 75 |
$targetDataParams['page_selected'] = apply_filters('sgpmPopupTargetPageSelected', array()); |
| 76 |
$targetDataParams['post_type'] = apply_filters('sgpmPopupTargetPostType', SGPMHelper::getAllCustomPostTypes()); |
| 77 |
$targetDataParams['post_category'] = apply_filters('sgpmPopupTargetPostType', SGPMHelper::getPostsAllCategories()); |
| 78 |
$targetDataParams['page_type'] = apply_filters('sgpmPopupTargetPostType', SGPMHelper::getPageTypes()); |
| 79 |
$targetDataParams['page_template'] = apply_filters('sgpmPopupPageTemplates', array()); |
| 80 |
$targetDataParams['post_all'] = null; |
| 81 |
$targetDataParams['page_all'] = null; |
| 82 |
|
| 83 |
$targetAttrs = array( |
| 84 |
'param' => array('class' => 'js-sgpm-select2 js-select-basic', 'data-select-type' => 'basic', 'autocomplete' => 'off'), |
| 85 |
'operator' => array('class' => 'js-sgpm-select2 js-select-basic', 'data-select-type' => 'basic'), |
| 86 |
'post_selected' => array('class' => 'js-sgpm-select2 js-select-ajax', 'isNotPostType' => false, 'data-select-type' => 'ajax', 'data-value-param' => 'post', 'multiple' => 'multiple'), |
| 87 |
'page_selected' => array('class' => 'js-sgpm-select2 js-select-ajax', 'data-select-type' => 'ajax', 'data-value-param' => 'page', 'multiple' => 'multiple'), |
| 88 |
'post_type' => array('class' => 'js-sgpm-select2 js-select-ajax', 'data-select-type' => 'multiple', 'data-value-param' => 'postTypes', 'isNotPostType' => true, 'multiple' => 'multiple'), |
| 89 |
'post_category' => array('class' => 'js-sgpm-select2 js-select-ajax', 'data-select-type' => 'multiple', 'data-value-param' => 'postCategories', 'isNotPostType' => true, 'multiple' => 'multiple'), |
| 90 |
'page_type' => array('class' => 'js-sgpm-select2 js-select-ajax', 'data-select-type' => 'multiple', 'data-value-param' => 'postCategories', 'isNotPostType' => true, 'multiple' => 'multiple'), |
| 91 |
'page_template' => array('class' => 'js-sgpm-select2 js-select-ajax', 'data-select-type' => 'multiple', 'data-value-param' => 'pageTemplate', 'isNotPostType' => true, 'multiple' => 'multiple') |
| 92 |
); |
| 93 |
|
| 94 |
$popupTarget['columnTypes'] = apply_filters('sgpmPopupTargetTypes', $targetElementTypes); |
| 95 |
$popupTarget['paramsData'] = apply_filters('sgpmPopupTargetData', $targetDataParams); |
| 96 |
$popupTarget['initialData'] = apply_filters('sgpmPopupTargetInitialData', $targetInitialData); |
| 97 |
$popupTarget['operators'] = apply_filters('sgpmPopupTargetOperators', $targetOperators); |
| 98 |
$popupTarget['attrs'] = apply_filters('sgpmPopupTargetAttrs', $targetAttrs); |
| 99 |
|
| 100 |
$SGPM_DATA_CONFIG_ARRAY['displayTarget'] = $popupTarget; |
| 101 |
} |
| 102 |
} |
| 103 |
|