| 1 |
<?php |
| 2 |
|
| 3 |
namespace BitCode\BitForm\Core\Fallback; |
| 4 |
|
| 5 |
use BitCode\BitForm\Core\Database\SuccessMessageModel; |
| 6 |
|
| 7 |
class Message |
| 8 |
{ |
| 9 |
public function confirmation() |
| 10 |
{ |
| 11 |
$sucMsgMdl = new SuccessMessageModel(); |
| 12 |
$messages = $sucMsgMdl->get( |
| 13 |
['id', 'message_config'] |
| 14 |
); |
| 15 |
|
| 16 |
if (!is_wp_error($messages)) { |
| 17 |
foreach ($messages as $msg) { |
| 18 |
$messageId = $msg->id; |
| 19 |
$messageConfig = new \stdClass(); |
| 20 |
$messageConfig->msgType = 'snackbar'; |
| 21 |
$messageConfig->position = 'bottom-right'; |
| 22 |
$messageConfig->animation = 'slide-up'; |
| 23 |
$messageConfig->autoHide = true; |
| 24 |
$messageConfig->duration = 5; |
| 25 |
|
| 26 |
$styles = [ |
| 27 |
'width' => '300px', |
| 28 |
'padding' => '5px 35px 5px 20px', |
| 29 |
'background' => '#fafafa', |
| 30 |
'color' => '#000000', |
| 31 |
'borderWidth' => '1px', |
| 32 |
'borderType' => 'solid', |
| 33 |
'borderColor' => 'gray', |
| 34 |
'borderRadius' => '10px', |
| 35 |
'boxShadow' => [ |
| 36 |
[ |
| 37 |
'x' => '0px', |
| 38 |
'y' => '27px', |
| 39 |
'blur' => '30px', |
| 40 |
'spread' => '', |
| 41 |
'color' => "rgb(0 0 0 \/ 18%)", |
| 42 |
'inset' => '', |
| 43 |
], |
| 44 |
[ |
| 45 |
'x' => '0px', |
| 46 |
'y' => '5.2px', |
| 47 |
'blur' => '9.4px', |
| 48 |
'spread' => '5px', |
| 49 |
'color' => "rgb(0 0 0 \/ 6%)", |
| 50 |
'inset' => '', |
| 51 |
], |
| 52 |
[ |
| 53 |
'x' => '0px', |
| 54 |
'y' => '11.1px', |
| 55 |
'blur' => '14px', |
| 56 |
'spread' => '', |
| 57 |
'color' => "rgb(0 0 0 \/ 14%)", |
| 58 |
'inset' => '', |
| 59 |
], |
| 60 |
], |
| 61 |
'closeBackground' => '#48484829', |
| 62 |
'closeHover' => '#dfdfdf', |
| 63 |
'closeIconColor' => '#5a5a5a', |
| 64 |
'closeIconHover' => '#000', |
| 65 |
]; |
| 66 |
|
| 67 |
$stylesObj = [ |
| 68 |
".msg-container-$messageId" => [ |
| 69 |
'display' => 'flex', |
| 70 |
'justify-content' => 'center', |
| 71 |
'align-items' => 'center', |
| 72 |
'position' => 'fixed', |
| 73 |
'z-ndex' => 999, |
| 74 |
'width' => '300px', |
| 75 |
'height' => 'auto', |
| 76 |
'visibility' => 'hidden', |
| 77 |
'opacity' => 0, |
| 78 |
'transition' => 'opacity 0.4s', |
| 79 |
'left' => '50%', |
| 80 |
'margin-eft' => '-200px', |
| 81 |
'top' => '30px', |
| 82 |
], |
| 83 |
".msg-container-$messageId.active" => [ |
| 84 |
'opacity' => 1, |
| 85 |
'visibility' => 'visible', |
| 86 |
], |
| 87 |
".msg-container-$messageId.deactive" => [ |
| 88 |
'opacity' => 0, |
| 89 |
'visibility' => 'hidden', |
| 90 |
'transition' => 'opacity 0.4s, visibility 0s ease-out 0.4s', |
| 91 |
], |
| 92 |
".msg-background-$messageId" => [ |
| 93 |
'width' => '100%', |
| 94 |
'height' => '100%', |
| 95 |
'display' => 'flex', |
| 96 |
'justify-content' => 'center', |
| 97 |
'align-items' => 'center', |
| 98 |
'background' => 'rgba(0, 0, 0, 0.0)', |
| 99 |
], |
| 100 |
".msg-content-$messageId" => [ |
| 101 |
'background' => '#fafafa', |
| 102 |
'padding' => '5px 35px 5px 20px', |
| 103 |
'border-width' => '1px', |
| 104 |
'border-style' => 'solid', |
| 105 |
'border-color' => 'gray', |
| 106 |
'border-radius' => '10px', |
| 107 |
'width' => '100%', |
| 108 |
'margin' => 'auto', |
| 109 |
'position' => 'relative', |
| 110 |
'word-break' => 'break-all', |
| 111 |
'box-shadow' => '0px 27px 30px rgb(0 0 0 / 18%) ,0px 5.2px 9.4px 5px rgb(0 0 0 / 6%) ,0px 11.1px 14px rgb(0 0 0 / 14%) ', |
| 112 |
], |
| 113 |
".close-$messageId" => [ |
| 114 |
'color' => '#5a5a5a', |
| 115 |
'background' => '#48484829', |
| 116 |
'position' => 'absolute', |
| 117 |
'right' => '7px', |
| 118 |
'top' => '50%', |
| 119 |
'transform' => 'translateY(-50%)', |
| 120 |
'height' => '25px', |
| 121 |
'width' => '25px', |
| 122 |
'border' => 'none', |
| 123 |
'border-radius' => '50%', |
| 124 |
'padding' => 0, |
| 125 |
'display' => 'grid', |
| 126 |
'place-content' => 'center', |
| 127 |
'cursor' => 'pointer', |
| 128 |
], |
| 129 |
".close-$messageId:hover" => [ |
| 130 |
'color' => '#000', |
| 131 |
'background' => '#dfdfdf', |
| 132 |
], |
| 133 |
".close-$messageId:focus" => [ |
| 134 |
'color' => '#000', |
| 135 |
], |
| 136 |
".close-icn-$messageId" => [ |
| 137 |
'width' => '15px', |
| 138 |
'height' => '15px', |
| 139 |
'stroke-width' => 2, |
| 140 |
], |
| 141 |
]; |
| 142 |
|
| 143 |
$messageConfig->styles = $styles; |
| 144 |
$messageConfig->stylesObj = $stylesObj; |
| 145 |
|
| 146 |
$sucMsgMdl->update( |
| 147 |
[ |
| 148 |
'message_config' => wp_json_encode($messageConfig), |
| 149 |
], |
| 150 |
[ |
| 151 |
'id' => $messageId, |
| 152 |
] |
| 153 |
); |
| 154 |
} |
| 155 |
} |
| 156 |
} |
| 157 |
} |
| 158 |
|