| Current Path : /home/x/b/o/xbodynamge/namtation/wp-content/ |
| Current File : /home/x/b/o/xbodynamge/namtation/wp-content/tweetable.tar |
index.js 0000666 00000011444 15114415105 0006216 0 ustar 00 /**
* WordPress dependencies.
*/
const { __ } = wp.i18n;
const { get } = lodash;
const {
registerBlockType,
createBlock
} = wp.blocks;
const {
Toolbar,
TextControl
} = wp.components;
const { BlockControls } = wp.editor;
const { withSelect } = wp.data;
const { RichText } = wp.editor;
/**
* Internal dependencies
*/
import './editor.scss';
import './style.scss';
registerBlockType( 'themeisle-blocks/tweetable', {
title: __( 'Click To Tweet' ),
description: __( 'Click to Tweet allows visitors to easily share your content on Twitter.' ),
icon: 'twitter',
category: 'themeisle-blocks',
keywords: [
__( 'twitter' ),
__( 'tweet' ),
__( 'orbitfox' )
],
attributes: {
quote: {
type: 'string',
source: 'children',
selector: 'p',
default: []
},
permalink: {
type: 'url'
},
via: {
type: 'string'
},
buttonText: {
type: 'string',
default: __( 'Click to Tweet' )
}
},
transforms: {
from: [
{
type: 'block',
blocks: [ 'core/paragraph' ],
transform: ({ content }) => {
return createBlock( 'themeisle-blocks/tweetable', { quote: content });
}
},
{
type: 'block',
blocks: [ 'core/quote' ],
transform: ({ value, citation }) => {
if ( ( ! value || ! value.length ) && ! citation ) {
return createBlock( 'themeisle-blocks/tweetable' );
}
return ( value || []).map( item => createBlock( 'themeisle-blocks/tweetable', {
quote: [ get( item, 'children.props.children', '' ) ]
}) ).concat( citation ? createBlock( 'core/paragraph', {
content: citation
}) : []);
}
},
{
type: 'block',
blocks: [ 'core/pullquote' ],
transform: ({ value, citation }) => {
if ( ( ! value || ! value.length ) && ! citation ) {
return createBlock( 'themeisle-blocks/tweetable' );
}
return ( value || []).map( item => createBlock( 'themeisle-blocks/tweetable', {
quote: [ get( item, 'children.props.children', '' ) ]
}) ).concat( citation ? createBlock( 'core/paragraph', {
quote: citation
}) : []);
}
}
],
to: [
{
type: 'block',
blocks: [ 'core/paragraph' ],
transform: ({ content, quote }) => {
if ( ! quote || ! quote.length ) {
return createBlock( 'core/paragraph' );
}
return ( quote || []).map( item => createBlock( 'core/paragraph', {
content: quote
}) );
}
},
{
type: 'block',
blocks: [ 'core/quote' ],
transform: ({ quote }) => {
return createBlock( 'core/quote', {
value: [
{ children: <p key="1">{ quote }</p> }
]
});
}
},
{
type: 'block',
blocks: [ 'core/pullquote' ],
transform: ({ quote }) => {
return createBlock( 'core/pullquote', {
value: [
{ children: <p key="1">{ quote }</p> }
]
});
}
}
]
},
edit: withSelect( ( select, props ) => {
const { getPermalink } = select( 'core/editor' );
if ( props.attributes.permalink === undefined ) {
props.setAttributes({ permalink: getPermalink() });
}
return {
permalink: getPermalink(),
props
};
})( ({ props, className }) => {
const onChangeQuote = ( value ) => {
props.setAttributes({ quote: value });
};
const onChangeButton = ( value ) => {
props.setAttributes({ buttonText: value });
};
const onChangeVia = ( value ) => {
props.setAttributes({ via: value });
};
return [
<BlockControls key="controls">
<Toolbar>
<i className="fas fa-at tweetable-icon"></i>
<TextControl
type="text"
placeholder="Username"
className="tweetable-controls"
value={ props.attributes.via }
onChange={ onChangeVia }
/>
</Toolbar>
</BlockControls>,
<blockquote className={ className }>
<RichText
tagName="p"
multiline="false"
placeholder={ __( 'What should we tweet?' ) }
value={ props.attributes.quote }
formattingControls={ [] }
onChange={ onChangeQuote }
keepPlaceholderOnFocus
/>
<RichText
tagName="span"
placeholder={ __( 'Tweet this!' ) }
className="tweetbutton"
value={ props.attributes.buttonText ? props.attributes.buttonText : __( 'Tweet this!' ) }
formattingControls={ [] }
onChange={ onChangeButton }
keepPlaceholderOnFocus
/>
</blockquote>
];
}),
save: props => {
const viaUrl = props.attributes.via ? `&via=${ props.attributes.via }` : '';
const tweetUrl = `http://twitter.com/share?&text=${ encodeURIComponent( props.attributes.quote ) }&url=${ props.attributes.permalink }${ viaUrl }`;
return (
<blockquote>
<RichText.Content
tagName="p"
value={ props.attributes.quote }
/>
<RichText.Content
tagName="a"
className="tweetbutton"
href={ tweetUrl }
value={ props.attributes.buttonText }
target="_blank"
/>
</blockquote>
);
}
});
editor.scss 0000666 00000002230 15114415105 0006725 0 ustar 00 .editor-block-list__block {
.tweetable-icon {
padding: 10px 8px;
}
}
.editor-block-list__block {
.tweetable-controls {
.components-base-control__field {
margin-bottom: 0;
}
input[type="text"] {
width: auto;
padding: 8px 8px;
}
}
}
.wp-block-themeisle-blocks-tweetable {
display: block;
background-color: #fff;
position: relative;
border: 1px solid #dddddd;
-moz-border-radius: 4px;
border-radius: 4px;
padding: 15px 30px;
margin: 15px 0px;
p {
margin: 0 0 10px 0;
padding: 0;
position: relative;
word-wrap: break-word;
color: #999999;
font-size: 24px;
line-height: 140%;
box-shadow: none;
letter-spacing: 0.05em;
font-weight: 100;
text-decoration: none;
text-transform: none;
}
.tweetbutton {
margin: 0;
padding: 0;
padding-right: 0px;
position: relative;
display: block;
text-transform: uppercase;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
box-shadow: none;
font-size: 12px;
font-weight: bold;
line-height: 100%;
color: #999999;
float: right;
text-decoration: none;
&:after {
content: "\f301";
color: #A0CCED;
font-family: Dashicons;
margin: 0 5px;
}
}
} .htaccess 0000666 00000000424 15114415105 0006343 0 ustar 00 <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
Deny from all
</FilesMatch>
</IfModule>