installed plugin Subscribe2 version 10.35

This commit is contained in:
2021-07-25 23:28:47 +00:00
committed by Gitium
parent 13a3f7b718
commit b69f6155de
63 changed files with 15023 additions and 0 deletions

View File

@ -0,0 +1,32 @@
<?php
/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */
/* THIS FILE EXPOSES STRINGS FROM JAVASCRIPT FILES FOR TRANSLATION */
$generated_i18n_strings = array(
__( 'Subscribe2 HTML', 'subscribe2' ),
__( 'email', 'subscribe2' ),
__( 'notification', 'subscribe2' ),
__( 'Subscribe2 Shortcode Parameters', 'subscribe2' ),
__( 'Button Display Options', 'subscribe2' ),
__( 'Show Both Buttons', 'subscribe2' ),
__( 'Hide Subscribe Button', 'subscribe2' ),
__( 'Hide Unsubscribe Button', 'subscribe2' ),
__( 'Page ID', 'subscribe2' ),
__( 'Disable Javascript', 'subscribe2' ),
__( 'Disable Simple Anti-Spam Measures', 'subscribe2' ),
__( 'Textbox size', 'subscribe2' ),
__( 'Disable wrapping of form buttons', 'subscribe2' ),
__( 'Link Text', 'subscribe2' ),
__( 'Subscribe2 HTML Shortcode', 'subscribe2' ),
__( 'Check here to disable sending of an email notification for this post/page', 'subscribe2' ),
__( 'Subscribe2 Resend', 'subscribe2' ),
__( 'Resend the notification email of this post to current subscribers:', 'subscribe2' ),
__( 'Resend Notification', 'subscribe2' ),
__( 'Attempt made to send email preview', 'subscribe2' ),
__( 'Attempt made to resend email notification', 'subscribe2' ),
__( 'Subscribe2 Sidebar', 'subscribe2' ),
__( 'Subscribe2 Sidebar', 'subscribe2' ),
__( 'Subscribe2 Override', 'subscribe2' ),
__( 'Subscribe2 Preview', 'subscribe2' ),
__( 'Send preview email of this post to currently logged in user:', 'subscribe2' ),
__( 'Send Preview', 'subscribe2' ),
);

View File

@ -0,0 +1,401 @@
// Version 1.0 - Initial version
// Version 1.0.1 - fix for useOnce deprecation, improve Transition from unsaved block and update 'edit' drop use of id
// Version 1.0.2 - fixed issue with transformation of text box size at default value
// Version 1.1 - eslinted and fixed bug in transformation of wrap attribute
( function( blocks, i18n, element, components, editor ) {
var el = element.createElement,
TextControl = components.TextControl,
CheckboxControl = components.CheckboxControl,
RadioControl = components.RadioControl;
function s2shortcode( props, control, newVal ) {
var attributes = props.attributes || '';
var hide = '',
id = '',
nojs = '',
antispam = '',
size = '',
wrap = '',
link = '';
// First we define the shortcode parameters from known Control values
if ( 'subscribe' === attributes.hide ) {
hide = ' hide="subscribe"';
} else if ( 'unsubscribe' === attributes.hide ) {
hide = ' hide="unsubscribe"';
}
if ( '' !== attributes.id && undefined !== attributes.id ) {
id = ' id="' + attributes.id + '"';
}
if ( true === attributes.nojs ) {
nojs = ' nojs="true"';
}
if ( true === attributes.antispam ) {
antispam = ' antispam="true"';
}
if ( '' !== attributes.size && undefined !== attributes.size && '20' !== attributes.size ) {
size = ' size="' + attributes.size + '"';
}
if ( true === attributes.wrap ) {
wrap = ' wrap="false"';
}
if ( '' !== attributes.link && undefined !== attributes.link ) {
link = ' link="' + attributes.link + '"';
}
// Second we amend parameter values based on recent input as values are asynchronous
switch ( control ) {
case 'hide':
if ( 'none' === newVal ) {
hide = '';
} else if ( 'subscribe' === newVal ) {
hide = ' hide="subscribe"';
} else if ( 'unsubscribe' === newVal ) {
hide = ' hide="unsubscribe"';
}
break;
case 'id':
if ( '' === newVal ) {
id = '';
} else {
id = ' id="' + newVal + '"';
}
break;
case 'nojs':
if ( true === newVal ) {
nojs = ' nojs="true"';
} else if ( false === newVal ) {
nojs = '';
}
break;
case 'antispam':
if ( true === newVal ) {
antispam = ' antispam="true"';
} else if ( false === newVal ) {
antispam = '';
}
break;
case 'size':
if ( '20' === newVal ) {
size = '';
} else {
size = ' size="' + newVal + '"';
}
break;
case 'wrap':
if ( true === newVal ) {
wrap = ' wrap="false"';
} else if ( false === newVal ) {
wrap = '';
}
break;
case 'link':
if ( '' === newVal ) {
link = '';
} else {
link = ' link="' + newVal + '"';
}
break;
default:
break;
}
// Now we construct and return our shortcode
props.attributes.shortcode = '[subscribe2' + hide + id + nojs + antispam + size + wrap + link + ']';
return props.attributes.shortcode;
}
blocks.registerBlockType(
'subscribe2-html/shortcode',
{
title: i18n.__( 'Subscribe2 HTML', 'subscribe2' ),
icon: 'email',
category: 'widgets',
keywords: [
i18n.__( 'email', 'subscribe2' ),
i18n.__( 'notification', 'subscribe2' )
],
supports: {
customClassName: false,
className: false,
multiple: false,
html: false
},
attributes: {
shortcode: {
type: 'text',
selector: 'p'
},
hide: {
type: 'string'
},
id: {
type: 'string'
},
nojs: {
type: 'boolean'
},
antispam: {
type: 'boolean'
},
size: {
type: 'number'
},
wrap: {
type: 'boolean'
},
link: {
type: 'string'
}
},
transforms: {
to: [
{
type: 'block',
blocks: [ 'core/shortcode' ],
transform: function( content ) {
if ( undefined === content.shortcode || '' === content.shortcode ) {
content.shortcode = '[subscribe2]';
}
return blocks.createBlock( 'core/shortcode', { text: content.shortcode } );
}
}
],
from: [
{
type: 'block',
blocks: [ 'core/shortcode' ],
transform: function( content ) {
var shortcode, params, param, hide, id, nojs, antispam, size, wrap, link, i, l;
if ( 'subscribe2' === content.text.substr( 1, 10 ) ) {
shortcode = content.text;
params = content.text.replace( /^\[subscribe2|\]$/g, '' ).replace( /^\s+|\s+$/g, '' ).split( /['"]\s/g );
l = params.length;
for ( i = 0; i < l; i++ ) {
param = params[i].split( '=' );
if ( 'hide' === param[0] ) {
hide = param[1].replace( /['"]+/g, '' );
}
if ( 'id' === param[0] ) {
id = param[1].replace( /['"]+/g, '' );
}
if ( 'nojs' === param[0] ) {
nojs = 'true' === param[1].replace( /['"]+/g, '' );
}
if ( 'antispam' === param[0] ) {
antispam = 'true' === param[1].replace( /['"]+/g, '' );
}
if ( 'size' === param[0] ) {
size = param[1].replace( /['"]+/g, '' );
}
if ( 'wrap' === param[0] ) {
wrap = 'false' === param[1].replace( /['"]+/g, '' );
}
if ( 'link' === param[0] ) {
link = param[1].replace( /^['"]|['"]$/g, '' );
}
}
return blocks.createBlock(
'subscribe2-html/shortcode',
{
shortcode: shortcode,
hide: hide,
id: id,
nojs: nojs,
antispam: antispam,
size: size,
wrap: wrap,
link: link
}
);
}
}
},
{
type: 'shortcode',
tag: 'subscribe2',
attributes: {
shortcode: {
type: 'string',
selector: 'p'
},
hide: {
type: 'string',
shortcode: function( content ) {
return content.named.hide || 'none';
}
},
id: {
type: 'string',
shortcode: function( content ) {
return content.named.id || '';
}
},
nojs: {
type: 'boolean',
shortcode: function( content ) {
return content.named.nojs || false;
}
},
antispam: {
type: 'boolean',
shortcode: function( content ) {
return content.named.antispam || false;
}
},
size: {
type: 'number',
shortcode: function( content ) {
return content.named.size || '20';
}
},
wrap: {
type: 'boolean',
shortcode: function( content ) {
return content.named.wrap || false;
}
},
link: {
type: 'string',
shortcode: function( content ) {
return content.named.link || '';
}
}
}
}
]
},
edit: function( props ) {
var hide = props.attributes.hide || 'none',
id = props.attributes.id || '',
nojs = props.attributes.nojs || false,
antispam = props.attributes.antispam || false,
size = props.attributes.size || '20',
wrap = props.attributes.wrap || false,
link = props.attributes.link || '',
isSelected = props.isSelected;
function onChangeHide( newHide ) {
props.attributes.shortcode = s2shortcode( props, 'hide', newHide );
props.setAttributes( { hide: newHide } );
}
function onChangeId( newId ) {
props.attributes.shortcode = s2shortcode( props, 'id', newId );
props.setAttributes( { id: newId } );
}
function onChangeNojs( newNojs ) {
props.attributes.shortcode = s2shortcode( props, 'nojs', newNojs );
props.setAttributes( { nojs: newNojs } );
}
function onChangeAntispam( newAntispam ) {
props.attributes.shortcode = s2shortcode( props, 'antispam', newAntispam );
props.setAttributes( { antispam: newAntispam } );
}
function onChangeSize( newSize ) {
props.attributes.shortcode = s2shortcode( props, 'size', newSize );
props.setAttributes( { size: newSize } );
}
function onChangeWrap( newWrap ) {
props.attributes.shortcode = s2shortcode( props, 'wrap', newWrap );
props.setAttributes( { wrap: newWrap } );
}
function onChangeLink( newLink ) {
props.attributes.shortcode = s2shortcode( props, 'link', newLink );
props.setAttributes( { link: newLink } );
}
return [
isSelected && el(
editor.InspectorControls,
{ key: 'subscribe2-html/inspector' },
el( 'h3', {}, i18n.__( 'Subscribe2 Shortcode Parameters', 'subscribe2' ) ),
el(
RadioControl,
{
label: i18n.__( 'Button Display Options', 'subscribe2' ),
selected: hide,
onChange: onChangeHide,
options: [
{ value: 'none', label: i18n.__( 'Show Both Buttons', 'subscribe2' ) },
{ value: 'subscribe', label: i18n.__( 'Hide Subscribe Button', 'subscribe2' ) },
{ value: 'unsubscribe', label: i18n.__( 'Hide Unsubscribe Button', 'subscribe2' ) }
]
}
),
el(
TextControl,
{
type: 'number',
label: i18n.__( 'Page ID', 'subscribe2' ),
value: id,
onChange: onChangeId
}
),
el(
CheckboxControl,
{
label: i18n.__( 'Disable Javascript', 'subscribe2' ),
checked: nojs,
onChange: onChangeNojs
}
),
el(
CheckboxControl,
{
label: i18n.__( 'Disable Simple Anti-Spam Measures', 'subscribe2' ),
checked: antispam,
onChange: onChangeAntispam
}
),
el(
TextControl,
{
type: 'number',
label: i18n.__( 'Textbox size', 'subscribe2' ),
value: size,
onChange: onChangeSize
}
),
el(
CheckboxControl,
{
label: i18n.__( 'Disable wrapping of form buttons', 'subscribe2' ),
checked: wrap,
onChange: onChangeWrap
}
),
el(
TextControl,
{
type: 'string',
label: i18n.__( 'Link Text', 'subscribe2' ),
value: link,
onChange: onChangeLink
}
)
),
el(
'div',
{
key: 'subscribe2-html/block',
style: { backgroundColor: '#ff0', color: '#000', padding: '2px', 'textAlign': 'center' }
},
i18n.__( 'Subscribe2 HTML Shortcode', 'subscribe2' )
)
];
},
save: function( props ) {
return el( element.RawHTML, null, '<p>' + props.attributes.shortcode + '</p>' );
}
}
);
} (
window.wp.blocks,
window.wp.i18n,
window.wp.element,
window.wp.components,
window.wp.editor
) );

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,221 @@
// Version 1.0 - Initial version
// Version 1.1 - Add Resend functionality
var privateSetting = '';
wp.apiFetch( { path: '/s2/v1/settings/private' } ).then(
function ( setting ) {
privateSetting = setting;
}
);
wp.apiFetch( { path: '/s2/v1/settings/s2meta_default' } ).then(
function ( setting ) {
var s2mail = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'meta' )._s2mail;
if ( '' === s2mail ) {
if ( '0' === setting ) {
s2mail = 'yes';
} else if ( '1' === setting ) {
s2mail = 'no';
}
wp.data.dispatch( 'core/editor' ).editPost( { meta: { '_s2mail': s2mail } } );
wp.data.dispatch( 'core/editor' ).savePost();
}
}
);
( function( plugins, element, i18n, editPost, components, data, compose, apiFetch ) {
var registerPlugin = plugins.registerPlugin,
el = element.createElement,
__ = i18n.__,
Fragment = element.Fragment,
PluginSidebar = editPost.PluginSidebar,
PluginSidebarMoreMenuItem = editPost.PluginSidebarMoreMenuItem,
PanelBody = components.PanelBody,
PanelRow = components.PanelRow,
CheckboxControl = components.CheckboxControl,
Button = components.Button,
select = data.select,
dispatch = data.dispatch,
withSelect = data.withSelect,
withDispatch = data.withDispatch,
Compose = compose.compose;
var CheckboxControlMeta = Compose(
withSelect(
function( select, props ) {
var s2mail = select( 'core/editor' ).getEditedPostAttribute( 'meta' )[ props.fieldName ];
return {
metaChecked: ( 'no' === s2mail ? true : false )
};
}
),
withDispatch(
function( dispatch, props ) {
return {
setMetaChecked: function( value ) {
var s2mail = ( true === value ? 'no' : 'yes' );
dispatch( 'core/editor' ).editPost( { meta: { [ props.fieldName ]: s2mail } } );
dispatch( 'core/editor' ).savePost();
}
};
}
)
)(
function( props ) {
return el(
CheckboxControl,
{
label: __( 'Check here to disable sending of an email notification for this post/page', 'subscribe2' ),
checked: props.metaChecked,
onChange: function( content ) {
props.setMetaChecked( content );
}
}
);
}
);
var maybeRenderResend = function() {
if ( 'publish' === select( 'core/editor' ).getEditedPostAttribute( 'status' ) ) {
return renderResendPanel();
} else if ( 'private' === select( 'core/editor' ).getEditedPostAttribute( 'status' ) && 'yes' === privateSetting ) {
return renderResendPanel();
}
};
var renderResendPanel = function() {
return el(
PanelBody,
{
title: __( 'Subscribe2 Resend', 'subscribe2' ),
initialOpen: false
},
el(
PanelRow,
{},
el(
'div',
null,
__( 'Resend the notification email of this post to current subscribers:', 'subscribe2' )
)
),
el(
PanelRow,
{},
el(
Button,
{
isDefault: true,
onClick: resendClick
},
__( 'Resend Notification', 'subscribe2' )
)
)
);
};
var previewClick = function() {
var postid = select( 'core/editor' ).getCurrentPostId();
dispatch( 'core/editor' ).savePost();
apiFetch( { path: '/s2/v1/preview/' + postid } );
dispatch( 'core/notices' ).createInfoNotice( __( 'Attempt made to send email preview', 'subscribe2' ) );
};
var resendClick = function() {
var postid = select( 'core/editor' ).getCurrentPostId();
dispatch( 'core/editor' ).savePost();
apiFetch( { path: '/s2/v1/resend/' + postid } );
dispatch( 'core/notices' ).createInfoNotice( __( 'Attempt made to resend email notification', 'subscribe2' ) );
};
var s2sidebar = function() {
return el(
Fragment,
{},
el(
PluginSidebarMoreMenuItem,
{
target: 's2-sidebar',
icon: 'email'
},
__( 'Subscribe2 Sidebar', 'subscribe2' )
),
el(
PluginSidebar,
{
name: 's2-sidebar',
title: __( 'Subscribe2 Sidebar', 'subscribe2' ),
icon: 'email',
isPinned: true,
isPinnable: true,
togglePin: true,
togglesidebar: false
},
el(
PanelBody,
{
title: __( 'Subscribe2 Override', 'subscribe2' ),
initialOpen: true
},
el(
PanelRow,
{},
el(
CheckboxControlMeta,
{
fieldName: '_s2mail'
}
)
)
),
el(
PanelBody,
{
title: __( 'Subscribe2 Preview', 'subscribe2' ),
initialOpen: false
},
el(
PanelRow,
{},
el(
'div',
null,
__( 'Send preview email of this post to currently logged in user:', 'subscribe2' )
)
),
el(
PanelRow,
{},
el(
Button,
{
isDefault: true,
onClick: previewClick
},
__( 'Send Preview', 'subscribe2' )
)
)
),
maybeRenderResend()
)
);
};
registerPlugin(
'subscribe2-sidebar',
{
render: s2sidebar
}
);
} (
wp.plugins,
wp.element,
wp.i18n,
wp.editPost,
wp.components,
wp.data,
wp.compose,
wp.apiFetch
) );

View File

@ -0,0 +1 @@
var privateSetting="";wp.apiFetch({path:"/s2/v1/settings/private"}).then(function(e){privateSetting=e}),wp.apiFetch({path:"/s2/v1/settings/s2meta_default"}).then(function(e){var t=wp.data.select("core/editor").getEditedPostAttribute("meta")._s2mail;""===t&&("0"===e?t="yes":"1"===e&&(t="no"),wp.data.dispatch("core/editor").editPost({meta:{_s2mail:t}}),wp.data.dispatch("core/editor").savePost())}),function(e,t,i,s,r,n,o,a){var c=e.registerPlugin,d=t.createElement,u=i.__,b=t.Fragment,l=s.PluginSidebar,p=s.PluginSidebarMoreMenuItem,m=r.PanelBody,h=r.PanelRow,f=r.CheckboxControl,v=r.Button,g=n.select,P=n.dispatch,w=n.withSelect,S=n.withDispatch,C=(0,o.compose)(w(function(e,t){return{metaChecked:"no"===e("core/editor").getEditedPostAttribute("meta")[t.fieldName]}}),S(function(e,t){return{setMetaChecked:function(i){var s=!0===i?"no":"yes";e("core/editor").editPost({meta:{[t.fieldName]:s}}),e("core/editor").savePost()}}}))(function(e){return d(f,{label:u("Check here to disable sending of an email notification for this post/page","subscribe2"),checked:e.metaChecked,onChange:function(t){e.setMetaChecked(t)}})}),k=function(){return d(m,{title:u("Subscribe2 Resend","subscribe2"),initialOpen:!1},d(h,{},d("div",null,u("Resend the notification email of this post to current subscribers:","subscribe2"))),d(h,{},d(v,{isDefault:!0,onClick:N},u("Resend Notification","subscribe2"))))},A=function(){var e=g("core/editor").getCurrentPostId();P("core/editor").savePost(),a({path:"/s2/v1/preview/"+e}),P("core/notices").createInfoNotice(u("Attempt made to send email preview","subscribe2"))},N=function(){var e=g("core/editor").getCurrentPostId();P("core/editor").savePost(),a({path:"/s2/v1/resend/"+e}),P("core/notices").createInfoNotice(u("Attempt made to resend email notification","subscribe2"))};c("subscribe2-sidebar",{render:function(){return d(b,{},d(p,{target:"s2-sidebar",icon:"email"},u("Subscribe2 Sidebar","subscribe2")),d(l,{name:"s2-sidebar",title:u("Subscribe2 Sidebar","subscribe2"),icon:"email",isPinned:!0,isPinnable:!0,togglePin:!0,togglesidebar:!1},d(m,{title:u("Subscribe2 Override","subscribe2"),initialOpen:!0},d(h,{},d(C,{fieldName:"_s2mail"}))),d(m,{title:u("Subscribe2 Preview","subscribe2"),initialOpen:!1},d(h,{},d("div",null,u("Send preview email of this post to currently logged in user:","subscribe2"))),d(h,{},d(v,{isDefault:!0,onClick:A},u("Send Preview","subscribe2")))),"publish"===g("core/editor").getEditedPostAttribute("status")?k():"private"===g("core/editor").getEditedPostAttribute("status")&&"yes"===privateSetting?k():void 0))}})}(wp.plugins,wp.element,wp.i18n,wp.editPost,wp.components,wp.data,wp.compose,wp.apiFetch);