Changeset 2338987
- Timestamp:
- 07/11/2020 07:36:38 AM (6 years ago)
- Location:
- qroko-blocks
- Files:
-
- 12 added
- 12 deleted
- 14 edited
- 1 copied
-
assets/banner-1544x500.png (modified) (1 prop) (previous)
-
assets/banner-772x250.png (modified) (1 prop) (previous)
-
assets/icon-128x128.png (modified) (1 prop) (previous)
-
assets/icon-256x256.png (modified) (1 prop) (previous)
-
assets/screenshot-1.png (added)
-
assets/screenshot-2.png (added)
-
tags/1.0.1 (copied) (copied from qroko-blocks/trunk)
-
tags/1.0.1/README.md (deleted)
-
tags/1.0.1/build/editors.asset.php (modified) (1 diff)
-
tags/1.0.1/build/editors.js (modified) (1 diff)
-
tags/1.0.1/functions/open-graph.php (modified) (4 diffs)
-
tags/1.0.1/languages (added)
-
tags/1.0.1/languages/qroko-blocks-ja-qroko-blocks-editors.json (added)
-
tags/1.0.1/languages/qroko-blocks-ja.mo (added)
-
tags/1.0.1/languages/qroko-blocks-ja.po (added)
-
tags/1.0.1/languages/qroko-blocks.pot (added)
-
tags/1.0.1/package-lock.json (deleted)
-
tags/1.0.1/package.json (deleted)
-
tags/1.0.1/qroko-blocks.php (modified) (3 diffs)
-
tags/1.0.1/readme.txt (modified) (2 diffs)
-
tags/1.0.1/screenshot-1.png (deleted)
-
tags/1.0.1/screenshot-2.png (deleted)
-
tags/1.0.1/src (deleted)
-
trunk/README.md (deleted)
-
trunk/build/editors.asset.php (modified) (1 diff)
-
trunk/build/editors.js (modified) (1 diff)
-
trunk/functions/open-graph.php (modified) (4 diffs)
-
trunk/languages (added)
-
trunk/languages/qroko-blocks-ja-qroko-blocks-editors.json (added)
-
trunk/languages/qroko-blocks-ja.mo (added)
-
trunk/languages/qroko-blocks-ja.po (added)
-
trunk/languages/qroko-blocks.pot (added)
-
trunk/package-lock.json (deleted)
-
trunk/package.json (deleted)
-
trunk/qroko-blocks.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/screenshot-1.png (deleted)
-
trunk/screenshot-2.png (deleted)
-
trunk/src (deleted)
Legend:
- Unmodified
- Added
- Removed
-
qroko-blocks/assets/banner-1544x500.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
qroko-blocks/assets/banner-772x250.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
qroko-blocks/assets/icon-128x128.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
qroko-blocks/assets/icon-256x256.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
qroko-blocks/tags/1.0.1/build/editors.asset.php
r2337723 r2338987 1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => ' 06debe0a59944065a9c31cc9ad06f7d8');1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '76525cd346420eb23b2e047470c64592'); -
qroko-blocks/tags/1.0.1/build/editors.js
r2337723 r2338987 4 4 Licensed under the MIT License (MIT), see 5 5 http://jedwatson.github.io/classnames 6 */!function(){"use strict";var o={}.hasOwnProperty;function l(){for(var e=[],t=0;t<arguments.length;t++){var a=arguments[t];if(a){var n=typeof a;if("string"===n||"number"===n)e.push(a);else if(Array.isArray(a)&&a.length){var c=l.apply(null,a);c&&e.push(c)}else if("object"===n)for(var r in a)o.call(a,r)&&a[r]&&e.push(r)}}return e.join(" ")}e.exports?(l.default=l,e.exports=l):void 0===(a=function(){return l}.apply(t,[]))||(e.exports=a)}()},function(e,t){!function(){e.exports=this.wp.blockEditor}()},function(e,t){!function(){e.exports=this.wp.blocks}()},function(e,t,o){},,function(e,t,o){"use strict";o.r(t);var a=o(0),l=o(2),n=o(5),c=o(4),r=o(1),i=o(3),s=o.n(i),m=(o(6),[{label: "左",value:"left"},{label:"右",value:"right"}]),b=[{label:"広げる",value:"cover"},{label:"収める",value:"contain"}];Object(n.registerBlockType)("qroko-blocks/blog-card",{title:Object(l.__)("ブログカード","qroko-blocks"),description:Object(l.__)("カード型のリンクを作るブロック。リンク先URLからOpen Graphを取得した後に編集もできます。","qroko-blocks"),category:"qroko",icon:Object(a.createElement)("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M14.5 3h-13a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5zm-13-1A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h13a1.5 1.5 0 0 0 1.5-1.5v-9A1.5 1.5 0 0 0 14.5 2h-13z"}),Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M3 5.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zM3 8a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9A.5.5 0 0 1 3 8zm0 2.5a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5z"})),attributes:{url:{type:"string",default:""},title:{type:"string",default:""},description:{type:"string",default:""},imageID:{type:"number",default:0},imageURL:{type:"string",default:""},imageAlt:{type:"string",default:""},imagePosition:{type:"string",default:"left"},imageFit:{type:"string",default:"cover"},ogDomain:{type:"string",default:""},ogTitleCharacterCount:{type:"number",default:50},ogDescriptionCharacterCount:{type:"number",default:60},ogImageURL:{type:"string",default:""},externalLink:{type:"boolean",default:!0}},edit:function(e){var t=e.attributes,o=e.className,n=e.setAttributes,i=e.isSelected,g=function(e){var o,a,c,r=new URL(e.url),i=r.hostname,s=location.hostname,m=function(){var o=t.ogTitleCharacterCount;return e.title.length>=o?e.title.substr(0,o)+" ...":e.title};n({title:m(),description:(c=t.ogDescriptionCharacterCount,e.description.length>=c?e.description.substr(0,c)+" ...":e.description),imageID:0,imageURL:"",imageAlt:m(),ogDomain:i,ogImageURL:(o="https:"===location.protocol,a=r.protocol,o&&"https:"!==a?(console.log(Object(l.__)("取得先の画像URLがhttpのため、Mixed contentとなるパスを防ぎました。","qroko-blocks")),""):e.image),externalLink:i!=s})};return Object(a.createElement)("div",{className:s()(o,"qroko-blocks-blog-card")},Object(a.createElement)(c.InspectorControls,null,Object(a.createElement)(r.PanelBody,{title:Object(l.__)("タイトル","qroko-blocks")},Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.TextareaControl,{value:t.title,onChange:function(e){n({title:e})}}),Object(a.createElement)(r.RangeControl,{value:t.ogTitleCharacterCount,label:Object(l.__)("取得文字数","qroko-blocks"),min:1,max:200,initialPosition:50,allowReset:!0,onChange:function(e){n({ogTitleCharacterCount:e||50})}}))),Object(a.createElement)(r.PanelBody,{title:Object(l.__)("概要","qroko-blocks")},Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.TextareaControl,{value:t.description,onChange:function(e){n({description:e})}}),Object(a.createElement)(r.RangeControl,{value:t.ogDescriptionCharacterCount,label:Object(l.__)("取得文字数","qroko-blocks"),min:1,max:200,initialPosition:60,allowReset:!0,onChange:function(e){n({ogDescriptionCharacterCount:e||60})}}))),Object(a.createElement)(r.PanelBody,{title:Object(l.__)("画像","qroko-blocks")},Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(c.MediaUpload,{onSelect:function(e){n({imageID:e.id,imageURL:e.url,imageAlt:e.alt})},type:"image",value:t.imageID,render:function(e){var o,c=e.open;return o=c,t.imageURL||t.ogImageURL?Object(a.createElement)("div",null,Object(a.createElement)(r.Button,{onClick:o,className:"qroko-blocks-blog-card-image-preview"},Object(a.createElement)("img",{src:t.imageURL?t.imageURL:t.ogImageURL?t.ogImageURL:"",alt:t.imageAlt})),Object(a.createElement)(r.Button,{onClick:function(){n({imageID:0,imageURL:"",imageAlt:"",ogImageURL:""})},className:"button"},Object(l.__)("画像を削除","qroko-blocks"))):Object(a.createElement)(r.Button,{onClick:o,className:"button"},Object(l.__)("画像を追加","qroko-blocks"))}})),Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.RadioControl,{label:Object(l.__)("画像位置","qroko-blocks"),selected:t.imagePosition,options:m,onChange:function(e){n({imagePosition:e})}})),Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.RadioControl,{label:Object(l.__)("画像の収め方","qroko-blocks"),selected:t.imageFit,options:b,onChange:function(e){n({imageFit:e})}})))),t.title&&Object(a.createElement)("div",{className:s()("qroko-blocks-blog-card-columns","right"===t.imagePosition?"is-reverse":"")},(t.imageURL||t.ogImageURL)&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-none"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-container"},i&&Object(a.createElement)((function(){return Object(a.createElement)("button",{className:"qroko-blocks-blog-card-delete-image-button",type:"button",onClick:function(){return n({imageID:0,imageAlt:"",imageURL:"",ogImageURL:""})}},Object(a.createElement)("svg",{className:"icon",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M11.854 4.146a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708-.708l7-7a.5.5 0 0 1 .708 0z"}),Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M4.146 4.146a.5.5 0 0 0 0 .708l7 7a.5.5 0 0 0 .708-.708l-7-7a.5.5 0 0 0-.708 0z"})))}),null),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-wrap"},Object(a.createElement)("img",{src:t.imageURL?t.imageURL:t.ogImageURL?t.ogImageURL:"",alt:t.imageAlt,className:s()("qroko-blocks-blog-card-image","is-"+t.imageFit)})))),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-padding is-flex-grow"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-meta"},t.title&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-heading"},t.title),t.description&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-description"},t.description),t.ogDomain&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-domain"},t.ogDomain)))),(i||!t.title)&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-columns is-padding is-gap is-bottom"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-grow"},Object(a.createElement)(r.TextControl,{label:Object(l.__)("リンク先URL","qroko-blocks"),value:t.url,onChange:function(e){n({url:e})},className:"is-margin-bottom-none"})),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-none"},Object(a.createElement)(r.Button,{onClick:function(){return e=t.url,(o=new FormData).append("action","open_graph"),o.append("target_url",e),void fetch(ajaxurl,{method:"POST",body:o,cache:"no-cache"}).then((function(e){return e.json()})).then((function(e){g(e[0])})).catch((function(e){console.log(e)}));var e,o},className:"button is-small"},Object(l.__)("情報を取得","qroko-blocks")))))},save:function(e){var t=e.attributes,o=e.className;return Object(a.createElement)("div",{className:s()(o,"qroko-blocks-blog-card")},t.externalLink?Object(a.createElement)("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"qroko-blocks-blog-card-link"}):Object(a.createElement)("a",{href:t.url,className:"qroko-blocks-blog-card-link"}),Object(a.createElement)("div",{className:s()("qroko-blocks-blog-card-columns","right"===t.imagePosition?"is-reverse":"")},(t.imageURL||t.ogImageURL)&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-none"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-container"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-wrap"},Object(a.createElement)("img",{src:t.imageURL?t.imageURL:t.ogImageURL?t.ogImageURL:"",alt:t.imageAlt,className:s()("qroko-blocks-blog-card-image","is-"+t.imageFit)})))),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-padding is-flex-grow"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-meta"},t.title&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-heading"},t.title),t.description&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-description"},t.description),t.ogDomain&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-domain"},t.ogDomain)))))}})}]);6 */!function(){"use strict";var o={}.hasOwnProperty;function l(){for(var e=[],t=0;t<arguments.length;t++){var a=arguments[t];if(a){var n=typeof a;if("string"===n||"number"===n)e.push(a);else if(Array.isArray(a)&&a.length){var c=l.apply(null,a);c&&e.push(c)}else if("object"===n)for(var r in a)o.call(a,r)&&a[r]&&e.push(r)}}return e.join(" ")}e.exports?(l.default=l,e.exports=l):void 0===(a=function(){return l}.apply(t,[]))||(e.exports=a)}()},function(e,t){!function(){e.exports=this.wp.blockEditor}()},function(e,t){!function(){e.exports=this.wp.blocks}()},function(e,t,o){},,function(e,t,o){"use strict";o.r(t);var a=o(0),l=o(2),n=o(5),c=o(4),r=o(1),i=o(3),s=o.n(i),m=(o(6),[{label:Object(l.__)("Left","qroko-blocks"),value:"left"},{label:Object(l.__)("Right","qroko-blocks"),value:"right"}]),b=[{label:Object(l.__)("Cover","qroko-blocks"),value:"cover"},{label:Object(l.__)("Contain","qroko-blocks"),value:"contain"}];Object(n.registerBlockType)("qroko-blocks/blog-card",{title:Object(l.__)("Blog Card","qroko-blocks"),description:Object(l.__)("Block to create a card link. You can also edit it after getting the Open Graph from the link URL.","qroko-blocks"),category:"qroko",icon:Object(a.createElement)("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M14.5 3h-13a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5zm-13-1A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h13a1.5 1.5 0 0 0 1.5-1.5v-9A1.5 1.5 0 0 0 14.5 2h-13z"}),Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M3 5.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zM3 8a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9A.5.5 0 0 1 3 8zm0 2.5a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5z"})),attributes:{url:{type:"string",default:""},title:{type:"string",default:""},description:{type:"string",default:""},imageID:{type:"number",default:0},imageURL:{type:"string",default:""},imageAlt:{type:"string",default:""},imagePosition:{type:"string",default:"left"},imageFit:{type:"string",default:"cover"},ogDomain:{type:"string",default:""},ogTitleCharacterCount:{type:"number",default:50},ogDescriptionCharacterCount:{type:"number",default:60},ogImageURL:{type:"string",default:""},externalLink:{type:"boolean",default:!0}},edit:function(e){var t=e.attributes,o=e.className,n=e.setAttributes,i=e.isSelected,g=function(e){var o,a=new URL(e.url).hostname,l=location.hostname,c=function(){var o=t.ogTitleCharacterCount;return(e.title?e.title.length:0)>=o?e.title.substr(0,o)+" ...":e.title};n({title:c(),description:(o=t.ogDescriptionCharacterCount,(e.description?e.description.length:0)>=o?e.description.substr(0,o)+" ...":e.description),imageID:0,imageURL:"",imageAlt:c(),ogDomain:a,ogImageURL:e.image,externalLink:a!=l})};return Object(a.createElement)("div",{className:s()(o,"qroko-blocks-blog-card")},Object(a.createElement)(c.InspectorControls,null,Object(a.createElement)(r.PanelBody,{title:Object(l.__)("Title","qroko-blocks")},Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.TextareaControl,{value:t.title,onChange:function(e){n({title:e})}}),Object(a.createElement)(r.RangeControl,{value:t.ogTitleCharacterCount,label:Object(l.__)("Number of characters","qroko-blocks"),min:1,max:200,initialPosition:50,allowReset:!0,onChange:function(e){n({ogTitleCharacterCount:e||50})}}))),Object(a.createElement)(r.PanelBody,{title:Object(l.__)("Description","qroko-blocks")},Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.TextareaControl,{value:t.description,onChange:function(e){n({description:e})}}),Object(a.createElement)(r.RangeControl,{value:t.ogDescriptionCharacterCount,label:Object(l.__)("Number of characters","qroko-blocks"),min:1,max:200,initialPosition:60,allowReset:!0,onChange:function(e){n({ogDescriptionCharacterCount:e||60})}}))),Object(a.createElement)(r.PanelBody,{title:Object(l.__)("Image","qroko-blocks")},Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(c.MediaUpload,{onSelect:function(e){n({imageID:e.id,imageURL:e.url,imageAlt:e.alt})},type:"image",value:t.imageID,render:function(e){var o,c=e.open;return o=c,t.imageURL||t.ogImageURL?Object(a.createElement)("div",null,Object(a.createElement)(r.Button,{onClick:o,className:"qroko-blocks-blog-card-image-preview"},Object(a.createElement)("img",{src:t.imageURL?t.imageURL:t.ogImageURL?t.ogImageURL:"",alt:t.imageAlt})),Object(a.createElement)(r.Button,{onClick:function(){n({imageID:0,imageURL:"",imageAlt:"",ogImageURL:""})},className:"button"},Object(l.__)("Delete image","qroko-blocks"))):Object(a.createElement)(r.Button,{onClick:o,className:"button"},Object(l.__)("Add Image","qroko-blocks"))}})),Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.RadioControl,{label:Object(l.__)("Image position","qroko-blocks"),selected:t.imagePosition,options:m,onChange:function(e){n({imagePosition:e})}})),Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.RadioControl,{label:Object(l.__)("Image Fit","qroko-blocks"),selected:t.imageFit,options:b,onChange:function(e){n({imageFit:e})}})))),t.title&&Object(a.createElement)("div",{className:s()("qroko-blocks-blog-card-columns","right"===t.imagePosition?"is-reverse":"")},(t.imageURL||t.ogImageURL)&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-none"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-container"},i&&Object(a.createElement)((function(){return Object(a.createElement)("button",{className:"qroko-blocks-blog-card-delete-image-button",type:"button",onClick:function(){return n({imageID:0,imageAlt:"",imageURL:"",ogImageURL:""})}},Object(a.createElement)("svg",{className:"icon",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M11.854 4.146a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708-.708l7-7a.5.5 0 0 1 .708 0z"}),Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M4.146 4.146a.5.5 0 0 0 0 .708l7 7a.5.5 0 0 0 .708-.708l-7-7a.5.5 0 0 0-.708 0z"})))}),null),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-wrap"},Object(a.createElement)("img",{src:t.imageURL?t.imageURL:t.ogImageURL?t.ogImageURL:"",alt:t.imageAlt,className:s()("qroko-blocks-blog-card-image","is-"+t.imageFit)})))),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-padding is-flex-grow"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-meta"},t.title&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-heading"},t.title),t.description&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-description"},t.description),t.ogDomain&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-domain"},t.ogDomain)))),(i||!t.title)&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-columns is-padding is-gap is-bottom"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-grow"},Object(a.createElement)(r.TextControl,{label:Object(l.__)("Link URL","qroko-blocks"),value:t.url,onChange:function(e){n({url:e})},className:"is-margin-bottom-none"})),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-none"},Object(a.createElement)(r.Button,{onClick:function(){return e=t.url,(o=new FormData).append("action","open_graph"),o.append("target_url",e),void fetch(ajaxurl,{method:"POST",body:o,cache:"no-cache"}).then((function(e){return e.json()})).then((function(e){g(e[0])})).catch((function(e){console.log(e)}));var e,o},className:"button is-small"},Object(l.__)("Load","qroko-blocks")))))},save:function(e){var t=e.attributes,o=e.className;return Object(a.createElement)("div",{className:s()(o,"qroko-blocks-blog-card")},t.externalLink?Object(a.createElement)("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"qroko-blocks-blog-card-link"}):Object(a.createElement)("a",{href:t.url,className:"qroko-blocks-blog-card-link"}),Object(a.createElement)("div",{className:s()("qroko-blocks-blog-card-columns","right"===t.imagePosition?"is-reverse":"")},(t.imageURL||t.ogImageURL)&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-none"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-container"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-wrap"},Object(a.createElement)("img",{src:t.imageURL?t.imageURL:t.ogImageURL?t.ogImageURL:"",alt:t.imageAlt,className:s()("qroko-blocks-blog-card-image","is-"+t.imageFit)})))),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-padding is-flex-grow"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-meta"},t.title&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-heading"},t.title),t.description&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-description"},t.description),t.ogDomain&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-domain"},t.ogDomain)))))}})}]); -
qroko-blocks/tags/1.0.1/functions/open-graph.php
r2337723 r2338987 1 1 <?php 2 /* 3 Copyright 2010 Scott MacVicar 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 http://www.apache.org/licenses/LICENSE-2.0 8 Unless required by applicable law or agreed to in writing, software 9 distributed under the License is distributed on an "AS IS" BASIS, 10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 See the License for the specific language governing permissions and 12 limitations under the License. 13 14 Original can be found at https://github.com/scottmac/opengraph/blob/master/OpenGraph.php 15 16 */ 17 18 class OpenGraph implements Iterator 19 { 2 /** 3 * Copyright 2010 Scott MacVicar 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * Unless required by applicable law or agreed to in writing, software 9 * distributed under the License is distributed on an "AS IS" BASIS, 10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 * See the License for the specific language governing permissions and 12 * limitations under the License. 13 * Original can be found at https://github.com/scottmac/opengraph/blob/master/OpenGraph.php 14 */ 15 16 class OpenGraph implements Iterator { 20 17 /** 21 18 * There are base schema's based on type, this is just … … 48 45 */ 49 46 static public function fetch($URI) { 50 $response = wp_remote_get($URI);51 52 if (!empty($response)) {53 return self::_parse($response['body']);54 } else {55 return false;56 }47 $response = wp_remote_get($URI); 48 49 if (!empty($response)) { 50 return self::_parse($response['body']); 51 } else { 52 return false; 53 } 57 54 } 58 55 … … 84 81 85 82 foreach ($tags AS $tag) { 86 if ($tag->hasAttribute('property') && 87 strpos($tag->getAttribute('property'), 'og:') === 0) { 83 if ($tag->hasAttribute('property') && strpos($tag->getAttribute('property'), 'og:') === 0) { 88 84 $key = strtr(substr($tag->getAttribute('property'), 3), '-', '_'); 89 85 $page->_values[$key] = $tag->getAttribute('content'); 90 86 } 91 87 92 //Added this if loop to retrieve description values from sites like the New York Times who have malformed it. 93 if ($tag ->hasAttribute('value') && $tag->hasAttribute('property') && 94 strpos($tag->getAttribute('property'), 'og:') === 0) { 88 // Added this if loop to retrieve description values from sites like the New York Times who have malformed it. 89 if ($tag ->hasAttribute('value') && $tag->hasAttribute('property') && strpos($tag->getAttribute('property'), 'og:') === 0) { 95 90 $key = strtr(substr($tag->getAttribute('property'), 3), '-', '_'); 96 91 $page->_values[$key] = $tag->getAttribute('value'); 97 92 } 98 //Based on modifications at https://github.com/bashofmann/opengraph/blob/master/src/OpenGraph/OpenGraph.php 93 94 // Based on modifications at https://github.com/bashofmann/opengraph/blob/master/src/OpenGraph/OpenGraph.php 99 95 if ($tag->hasAttribute('name') && $tag->getAttribute('name') === 'description') { 100 $nonOgDescription = $tag->getAttribute('content');101 }102 103 } 104 // Based on modifications at https://github.com/bashofmann/opengraph/blob/master/src/OpenGraph/OpenGraph.php96 $nonOgDescription = $tag->getAttribute('content'); 97 } 98 } 99 100 // Based on modifications at https://github.com/bashofmann/opengraph/blob/master/src/OpenGraph/OpenGraph.php 105 101 if (!isset($page->_values['title'])) { 106 $titles = $doc->getElementsByTagName('title'); 107 if ($titles->length > 0) { 108 $page->_values['title'] = $titles->item(0)->textContent; 109 } 102 $titles = $doc->getElementsByTagName('title'); 103 if ($titles->length > 0) { 104 $page->_values['title'] = $titles->item(0)->textContent; 105 } 106 } 107 108 if (!isset($page->_values['description']) && $nonOgDescription) { 109 $page->_values['description'] = $nonOgDescription; 110 } 111 112 // Fallback to use image_src if ogp::image isn't set. 113 if (!isset($page->values['image'])) { 114 $domxpath = new DOMXPath($doc); 115 $elements = $domxpath->query("//link[@rel='image_src']"); 116 117 if ($elements->length > 0) { 118 $domattr = $elements->item(0)->attributes->getNamedItem('href'); 119 if ($domattr) { 120 $page->_values['image'] = $domattr->value; 121 $page->_values['image_src'] = $domattr->value; 110 122 } 111 if (!isset($page->_values['description']) && $nonOgDescription) { 112 $page->_values['description'] = $nonOgDescription; 113 } 114 115 //Fallback to use image_src if ogp::image isn't set. 116 if (!isset($page->values['image'])) { 117 $domxpath = new DOMXPath($doc); 118 $elements = $domxpath->query("//link[@rel='image_src']"); 119 120 if ($elements->length > 0) { 121 $domattr = $elements->item(0)->attributes->getNamedItem('href'); 122 if ($domattr) { 123 $page->_values['image'] = $domattr->value; 124 $page->_values['image_src'] = $domattr->value; 125 } 126 } 127 } 123 } 124 } 128 125 129 126 if (empty($page->_values)) { return false; } … … 212 209 $og_type = $graph->type; 213 210 211 $esc_og_title = esc_html($og_title); 212 $esc_og_description = esc_html($og_description); 213 $esc_og_url = esc_url($og_url); 214 $esc_og_image = esc_url($og_image); 215 $esc_og_type = esc_html($og_type); 216 217 $merge_esc_url = ($esc_og_url === null) ? $esc_target_url : $esc_og_url; 218 219 $match_protocol = is_ssl() ? '|^https://.*$|' : '|^https?://.*$|'; 220 $filter_esc_image = preg_match($match_protocol, $esc_og_image) ? $esc_og_image : null; 221 214 222 $records[] = array( 215 'title' => $ og_title,216 'description' => $ og_description,217 'url' => $ og_url,218 'image' => $ og_image,219 'type' => $ og_type223 'title' => $esc_og_title, 224 'description' => $esc_og_description, 225 'url' => $merge_esc_url, 226 'image' => $filter_esc_image, 227 'type' => $esc_og_type 220 228 ); 229 230 // Debug: Chrome 231 //include '../debug/ChromePhp.php'; 232 //ChromePhp::log(json_encode($records)); 221 233 222 234 echo json_encode($records); -
qroko-blocks/tags/1.0.1/qroko-blocks.php
r2337723 r2338987 6 6 * Author: qrac 7 7 * Author URI: https://qrac.jp/ 8 * Version: 1.0.0 8 * Version: 1.0.1 9 * Text Domain: qroko-blocks 10 * Domain Path: /languages 9 11 * License: GPL2+ 10 12 * License URI: https://www.gnu.org/licenses/gpl-2.0.txt … … 22 24 23 25 function qroko_blocks_load_textdomain() { 24 load_plugin_textdomain( 'qroko-blocks', false, basename( __DIR__) . '/languages' );26 load_plugin_textdomain( 'qroko-blocks', false, basename( dirname( __FILE__ ) ) . '/languages' ); 25 27 } 26 28 add_action( 'init', 'qroko_blocks_load_textdomain' ); … … 59 61 // Setting Translations 60 62 if ( function_exists( 'wp_set_script_translations' ) ) { 61 wp_set_script_translations( 'qroko-blocks', 'qroko-blocks' ); 63 wp_set_script_translations( 'qroko-blocks-editors', 'qroko-blocks', 64 plugin_dir_path( __FILE__ ) . 'languages/' ); 62 65 } 63 66 -
qroko-blocks/tags/1.0.1/readme.txt
r2337723 r2338987 5 5 Requires at least: 5.4 6 6 Tested up to: 5.4 7 Stable tag: 1.0. 08 Requires PHP: 7.4.17 Stable tag: 1.0.1 8 Requires PHP: 5.6 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 14 14 == Description == 15 15 16 Qroko Blocks は Gutenberg にカスタムブロックを追加するプラグインです。16 Qroko Blocks is a plugin to add custom blocks to Gutenberg. It is listed in the official WordPress plugin directory. 17 17 18 「日本語環境で Gutenberg を使った場合に執筆が快適であること」を主眼として開発。主に、WordPress を headless CMS として使うテーマ「Qroko」での利用を想定していますが、他のテーマでも使えるよう依存性のない設計を心がけています。 18 Our main goal was to make writing on Gutenberg easier. Mainly used with the theme "Qroko", which uses WordPress as a headless CMS. However, we have tried to design it so that it is not dependent on other themes as well. 19 19 20 Qroko:https://github.com/qrac/qroko 20 The motif is a kabuki kuroko, which will play an active role offstage in your website production. 21 21 22 モチーフは歌舞伎の黒子です。Web サイト制作の舞台袖で活躍してくれることでしょう。 22 * Qroko: https://github.com/qrac/qroko 23 * Qroko Blocks: https://github.com/qrac/qroko-blocks 23 24 24 25 == Detail == 25 26 26 * ブログカード27 * Blog Card 27 28 28 29 == Frequently Asked Questions == 29 30 30 = どのテーマでも使えますか?=31 = Can I use it with any theme? = 31 32 32 はい。Gutenberg を有効化しているすべてのテーマで使えます。 33 Yes, you can use it with any theme that has Gutenberg enabled. 33 34 34 35 == Screenshots == 35 36 36 1. screenshot-1.png37 2. screenshot-2.png37 1. Blog Card (Editor) 38 2. Blog Card (Front) 38 39 39 40 == Changelog == 40 41 41 = 1.0.0 = 42 * First release 43 44 == Upgrade Notice == 42 = 1.0.1 = 43 * Fix Blog Card: Works without Open Graph 44 * Translation support 45 45 46 46 = 1.0.0 = -
qroko-blocks/trunk/build/editors.asset.php
r2337723 r2338987 1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => ' 06debe0a59944065a9c31cc9ad06f7d8');1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '76525cd346420eb23b2e047470c64592'); -
qroko-blocks/trunk/build/editors.js
r2337723 r2338987 4 4 Licensed under the MIT License (MIT), see 5 5 http://jedwatson.github.io/classnames 6 */!function(){"use strict";var o={}.hasOwnProperty;function l(){for(var e=[],t=0;t<arguments.length;t++){var a=arguments[t];if(a){var n=typeof a;if("string"===n||"number"===n)e.push(a);else if(Array.isArray(a)&&a.length){var c=l.apply(null,a);c&&e.push(c)}else if("object"===n)for(var r in a)o.call(a,r)&&a[r]&&e.push(r)}}return e.join(" ")}e.exports?(l.default=l,e.exports=l):void 0===(a=function(){return l}.apply(t,[]))||(e.exports=a)}()},function(e,t){!function(){e.exports=this.wp.blockEditor}()},function(e,t){!function(){e.exports=this.wp.blocks}()},function(e,t,o){},,function(e,t,o){"use strict";o.r(t);var a=o(0),l=o(2),n=o(5),c=o(4),r=o(1),i=o(3),s=o.n(i),m=(o(6),[{label: "左",value:"left"},{label:"右",value:"right"}]),b=[{label:"広げる",value:"cover"},{label:"収める",value:"contain"}];Object(n.registerBlockType)("qroko-blocks/blog-card",{title:Object(l.__)("ブログカード","qroko-blocks"),description:Object(l.__)("カード型のリンクを作るブロック。リンク先URLからOpen Graphを取得した後に編集もできます。","qroko-blocks"),category:"qroko",icon:Object(a.createElement)("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M14.5 3h-13a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5zm-13-1A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h13a1.5 1.5 0 0 0 1.5-1.5v-9A1.5 1.5 0 0 0 14.5 2h-13z"}),Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M3 5.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zM3 8a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9A.5.5 0 0 1 3 8zm0 2.5a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5z"})),attributes:{url:{type:"string",default:""},title:{type:"string",default:""},description:{type:"string",default:""},imageID:{type:"number",default:0},imageURL:{type:"string",default:""},imageAlt:{type:"string",default:""},imagePosition:{type:"string",default:"left"},imageFit:{type:"string",default:"cover"},ogDomain:{type:"string",default:""},ogTitleCharacterCount:{type:"number",default:50},ogDescriptionCharacterCount:{type:"number",default:60},ogImageURL:{type:"string",default:""},externalLink:{type:"boolean",default:!0}},edit:function(e){var t=e.attributes,o=e.className,n=e.setAttributes,i=e.isSelected,g=function(e){var o,a,c,r=new URL(e.url),i=r.hostname,s=location.hostname,m=function(){var o=t.ogTitleCharacterCount;return e.title.length>=o?e.title.substr(0,o)+" ...":e.title};n({title:m(),description:(c=t.ogDescriptionCharacterCount,e.description.length>=c?e.description.substr(0,c)+" ...":e.description),imageID:0,imageURL:"",imageAlt:m(),ogDomain:i,ogImageURL:(o="https:"===location.protocol,a=r.protocol,o&&"https:"!==a?(console.log(Object(l.__)("取得先の画像URLがhttpのため、Mixed contentとなるパスを防ぎました。","qroko-blocks")),""):e.image),externalLink:i!=s})};return Object(a.createElement)("div",{className:s()(o,"qroko-blocks-blog-card")},Object(a.createElement)(c.InspectorControls,null,Object(a.createElement)(r.PanelBody,{title:Object(l.__)("タイトル","qroko-blocks")},Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.TextareaControl,{value:t.title,onChange:function(e){n({title:e})}}),Object(a.createElement)(r.RangeControl,{value:t.ogTitleCharacterCount,label:Object(l.__)("取得文字数","qroko-blocks"),min:1,max:200,initialPosition:50,allowReset:!0,onChange:function(e){n({ogTitleCharacterCount:e||50})}}))),Object(a.createElement)(r.PanelBody,{title:Object(l.__)("概要","qroko-blocks")},Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.TextareaControl,{value:t.description,onChange:function(e){n({description:e})}}),Object(a.createElement)(r.RangeControl,{value:t.ogDescriptionCharacterCount,label:Object(l.__)("取得文字数","qroko-blocks"),min:1,max:200,initialPosition:60,allowReset:!0,onChange:function(e){n({ogDescriptionCharacterCount:e||60})}}))),Object(a.createElement)(r.PanelBody,{title:Object(l.__)("画像","qroko-blocks")},Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(c.MediaUpload,{onSelect:function(e){n({imageID:e.id,imageURL:e.url,imageAlt:e.alt})},type:"image",value:t.imageID,render:function(e){var o,c=e.open;return o=c,t.imageURL||t.ogImageURL?Object(a.createElement)("div",null,Object(a.createElement)(r.Button,{onClick:o,className:"qroko-blocks-blog-card-image-preview"},Object(a.createElement)("img",{src:t.imageURL?t.imageURL:t.ogImageURL?t.ogImageURL:"",alt:t.imageAlt})),Object(a.createElement)(r.Button,{onClick:function(){n({imageID:0,imageURL:"",imageAlt:"",ogImageURL:""})},className:"button"},Object(l.__)("画像を削除","qroko-blocks"))):Object(a.createElement)(r.Button,{onClick:o,className:"button"},Object(l.__)("画像を追加","qroko-blocks"))}})),Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.RadioControl,{label:Object(l.__)("画像位置","qroko-blocks"),selected:t.imagePosition,options:m,onChange:function(e){n({imagePosition:e})}})),Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.RadioControl,{label:Object(l.__)("画像の収め方","qroko-blocks"),selected:t.imageFit,options:b,onChange:function(e){n({imageFit:e})}})))),t.title&&Object(a.createElement)("div",{className:s()("qroko-blocks-blog-card-columns","right"===t.imagePosition?"is-reverse":"")},(t.imageURL||t.ogImageURL)&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-none"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-container"},i&&Object(a.createElement)((function(){return Object(a.createElement)("button",{className:"qroko-blocks-blog-card-delete-image-button",type:"button",onClick:function(){return n({imageID:0,imageAlt:"",imageURL:"",ogImageURL:""})}},Object(a.createElement)("svg",{className:"icon",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M11.854 4.146a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708-.708l7-7a.5.5 0 0 1 .708 0z"}),Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M4.146 4.146a.5.5 0 0 0 0 .708l7 7a.5.5 0 0 0 .708-.708l-7-7a.5.5 0 0 0-.708 0z"})))}),null),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-wrap"},Object(a.createElement)("img",{src:t.imageURL?t.imageURL:t.ogImageURL?t.ogImageURL:"",alt:t.imageAlt,className:s()("qroko-blocks-blog-card-image","is-"+t.imageFit)})))),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-padding is-flex-grow"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-meta"},t.title&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-heading"},t.title),t.description&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-description"},t.description),t.ogDomain&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-domain"},t.ogDomain)))),(i||!t.title)&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-columns is-padding is-gap is-bottom"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-grow"},Object(a.createElement)(r.TextControl,{label:Object(l.__)("リンク先URL","qroko-blocks"),value:t.url,onChange:function(e){n({url:e})},className:"is-margin-bottom-none"})),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-none"},Object(a.createElement)(r.Button,{onClick:function(){return e=t.url,(o=new FormData).append("action","open_graph"),o.append("target_url",e),void fetch(ajaxurl,{method:"POST",body:o,cache:"no-cache"}).then((function(e){return e.json()})).then((function(e){g(e[0])})).catch((function(e){console.log(e)}));var e,o},className:"button is-small"},Object(l.__)("情報を取得","qroko-blocks")))))},save:function(e){var t=e.attributes,o=e.className;return Object(a.createElement)("div",{className:s()(o,"qroko-blocks-blog-card")},t.externalLink?Object(a.createElement)("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"qroko-blocks-blog-card-link"}):Object(a.createElement)("a",{href:t.url,className:"qroko-blocks-blog-card-link"}),Object(a.createElement)("div",{className:s()("qroko-blocks-blog-card-columns","right"===t.imagePosition?"is-reverse":"")},(t.imageURL||t.ogImageURL)&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-none"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-container"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-wrap"},Object(a.createElement)("img",{src:t.imageURL?t.imageURL:t.ogImageURL?t.ogImageURL:"",alt:t.imageAlt,className:s()("qroko-blocks-blog-card-image","is-"+t.imageFit)})))),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-padding is-flex-grow"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-meta"},t.title&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-heading"},t.title),t.description&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-description"},t.description),t.ogDomain&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-domain"},t.ogDomain)))))}})}]);6 */!function(){"use strict";var o={}.hasOwnProperty;function l(){for(var e=[],t=0;t<arguments.length;t++){var a=arguments[t];if(a){var n=typeof a;if("string"===n||"number"===n)e.push(a);else if(Array.isArray(a)&&a.length){var c=l.apply(null,a);c&&e.push(c)}else if("object"===n)for(var r in a)o.call(a,r)&&a[r]&&e.push(r)}}return e.join(" ")}e.exports?(l.default=l,e.exports=l):void 0===(a=function(){return l}.apply(t,[]))||(e.exports=a)}()},function(e,t){!function(){e.exports=this.wp.blockEditor}()},function(e,t){!function(){e.exports=this.wp.blocks}()},function(e,t,o){},,function(e,t,o){"use strict";o.r(t);var a=o(0),l=o(2),n=o(5),c=o(4),r=o(1),i=o(3),s=o.n(i),m=(o(6),[{label:Object(l.__)("Left","qroko-blocks"),value:"left"},{label:Object(l.__)("Right","qroko-blocks"),value:"right"}]),b=[{label:Object(l.__)("Cover","qroko-blocks"),value:"cover"},{label:Object(l.__)("Contain","qroko-blocks"),value:"contain"}];Object(n.registerBlockType)("qroko-blocks/blog-card",{title:Object(l.__)("Blog Card","qroko-blocks"),description:Object(l.__)("Block to create a card link. You can also edit it after getting the Open Graph from the link URL.","qroko-blocks"),category:"qroko",icon:Object(a.createElement)("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M14.5 3h-13a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5zm-13-1A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h13a1.5 1.5 0 0 0 1.5-1.5v-9A1.5 1.5 0 0 0 14.5 2h-13z"}),Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M3 5.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zM3 8a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9A.5.5 0 0 1 3 8zm0 2.5a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5z"})),attributes:{url:{type:"string",default:""},title:{type:"string",default:""},description:{type:"string",default:""},imageID:{type:"number",default:0},imageURL:{type:"string",default:""},imageAlt:{type:"string",default:""},imagePosition:{type:"string",default:"left"},imageFit:{type:"string",default:"cover"},ogDomain:{type:"string",default:""},ogTitleCharacterCount:{type:"number",default:50},ogDescriptionCharacterCount:{type:"number",default:60},ogImageURL:{type:"string",default:""},externalLink:{type:"boolean",default:!0}},edit:function(e){var t=e.attributes,o=e.className,n=e.setAttributes,i=e.isSelected,g=function(e){var o,a=new URL(e.url).hostname,l=location.hostname,c=function(){var o=t.ogTitleCharacterCount;return(e.title?e.title.length:0)>=o?e.title.substr(0,o)+" ...":e.title};n({title:c(),description:(o=t.ogDescriptionCharacterCount,(e.description?e.description.length:0)>=o?e.description.substr(0,o)+" ...":e.description),imageID:0,imageURL:"",imageAlt:c(),ogDomain:a,ogImageURL:e.image,externalLink:a!=l})};return Object(a.createElement)("div",{className:s()(o,"qroko-blocks-blog-card")},Object(a.createElement)(c.InspectorControls,null,Object(a.createElement)(r.PanelBody,{title:Object(l.__)("Title","qroko-blocks")},Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.TextareaControl,{value:t.title,onChange:function(e){n({title:e})}}),Object(a.createElement)(r.RangeControl,{value:t.ogTitleCharacterCount,label:Object(l.__)("Number of characters","qroko-blocks"),min:1,max:200,initialPosition:50,allowReset:!0,onChange:function(e){n({ogTitleCharacterCount:e||50})}}))),Object(a.createElement)(r.PanelBody,{title:Object(l.__)("Description","qroko-blocks")},Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.TextareaControl,{value:t.description,onChange:function(e){n({description:e})}}),Object(a.createElement)(r.RangeControl,{value:t.ogDescriptionCharacterCount,label:Object(l.__)("Number of characters","qroko-blocks"),min:1,max:200,initialPosition:60,allowReset:!0,onChange:function(e){n({ogDescriptionCharacterCount:e||60})}}))),Object(a.createElement)(r.PanelBody,{title:Object(l.__)("Image","qroko-blocks")},Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(c.MediaUpload,{onSelect:function(e){n({imageID:e.id,imageURL:e.url,imageAlt:e.alt})},type:"image",value:t.imageID,render:function(e){var o,c=e.open;return o=c,t.imageURL||t.ogImageURL?Object(a.createElement)("div",null,Object(a.createElement)(r.Button,{onClick:o,className:"qroko-blocks-blog-card-image-preview"},Object(a.createElement)("img",{src:t.imageURL?t.imageURL:t.ogImageURL?t.ogImageURL:"",alt:t.imageAlt})),Object(a.createElement)(r.Button,{onClick:function(){n({imageID:0,imageURL:"",imageAlt:"",ogImageURL:""})},className:"button"},Object(l.__)("Delete image","qroko-blocks"))):Object(a.createElement)(r.Button,{onClick:o,className:"button"},Object(l.__)("Add Image","qroko-blocks"))}})),Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.RadioControl,{label:Object(l.__)("Image position","qroko-blocks"),selected:t.imagePosition,options:m,onChange:function(e){n({imagePosition:e})}})),Object(a.createElement)(r.BaseControl,null,Object(a.createElement)(r.RadioControl,{label:Object(l.__)("Image Fit","qroko-blocks"),selected:t.imageFit,options:b,onChange:function(e){n({imageFit:e})}})))),t.title&&Object(a.createElement)("div",{className:s()("qroko-blocks-blog-card-columns","right"===t.imagePosition?"is-reverse":"")},(t.imageURL||t.ogImageURL)&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-none"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-container"},i&&Object(a.createElement)((function(){return Object(a.createElement)("button",{className:"qroko-blocks-blog-card-delete-image-button",type:"button",onClick:function(){return n({imageID:0,imageAlt:"",imageURL:"",ogImageURL:""})}},Object(a.createElement)("svg",{className:"icon",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M11.854 4.146a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708-.708l7-7a.5.5 0 0 1 .708 0z"}),Object(a.createElement)("path",{"fill-rule":"evenodd",d:"M4.146 4.146a.5.5 0 0 0 0 .708l7 7a.5.5 0 0 0 .708-.708l-7-7a.5.5 0 0 0-.708 0z"})))}),null),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-wrap"},Object(a.createElement)("img",{src:t.imageURL?t.imageURL:t.ogImageURL?t.ogImageURL:"",alt:t.imageAlt,className:s()("qroko-blocks-blog-card-image","is-"+t.imageFit)})))),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-padding is-flex-grow"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-meta"},t.title&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-heading"},t.title),t.description&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-description"},t.description),t.ogDomain&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-domain"},t.ogDomain)))),(i||!t.title)&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-columns is-padding is-gap is-bottom"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-grow"},Object(a.createElement)(r.TextControl,{label:Object(l.__)("Link URL","qroko-blocks"),value:t.url,onChange:function(e){n({url:e})},className:"is-margin-bottom-none"})),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-none"},Object(a.createElement)(r.Button,{onClick:function(){return e=t.url,(o=new FormData).append("action","open_graph"),o.append("target_url",e),void fetch(ajaxurl,{method:"POST",body:o,cache:"no-cache"}).then((function(e){return e.json()})).then((function(e){g(e[0])})).catch((function(e){console.log(e)}));var e,o},className:"button is-small"},Object(l.__)("Load","qroko-blocks")))))},save:function(e){var t=e.attributes,o=e.className;return Object(a.createElement)("div",{className:s()(o,"qroko-blocks-blog-card")},t.externalLink?Object(a.createElement)("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"qroko-blocks-blog-card-link"}):Object(a.createElement)("a",{href:t.url,className:"qroko-blocks-blog-card-link"}),Object(a.createElement)("div",{className:s()("qroko-blocks-blog-card-columns","right"===t.imagePosition?"is-reverse":"")},(t.imageURL||t.ogImageURL)&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-flex-none"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-container"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-image-wrap"},Object(a.createElement)("img",{src:t.imageURL?t.imageURL:t.ogImageURL?t.ogImageURL:"",alt:t.imageAlt,className:s()("qroko-blocks-blog-card-image","is-"+t.imageFit)})))),Object(a.createElement)("div",{className:"qroko-blocks-blog-card-column is-padding is-flex-grow"},Object(a.createElement)("div",{className:"qroko-blocks-blog-card-meta"},t.title&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-heading"},t.title),t.description&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-description"},t.description),t.ogDomain&&Object(a.createElement)("div",{className:"qroko-blocks-blog-card-domain"},t.ogDomain)))))}})}]); -
qroko-blocks/trunk/functions/open-graph.php
r2337723 r2338987 1 1 <?php 2 /* 3 Copyright 2010 Scott MacVicar 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 http://www.apache.org/licenses/LICENSE-2.0 8 Unless required by applicable law or agreed to in writing, software 9 distributed under the License is distributed on an "AS IS" BASIS, 10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 See the License for the specific language governing permissions and 12 limitations under the License. 13 14 Original can be found at https://github.com/scottmac/opengraph/blob/master/OpenGraph.php 15 16 */ 17 18 class OpenGraph implements Iterator 19 { 2 /** 3 * Copyright 2010 Scott MacVicar 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * Unless required by applicable law or agreed to in writing, software 9 * distributed under the License is distributed on an "AS IS" BASIS, 10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 * See the License for the specific language governing permissions and 12 * limitations under the License. 13 * Original can be found at https://github.com/scottmac/opengraph/blob/master/OpenGraph.php 14 */ 15 16 class OpenGraph implements Iterator { 20 17 /** 21 18 * There are base schema's based on type, this is just … … 48 45 */ 49 46 static public function fetch($URI) { 50 $response = wp_remote_get($URI);51 52 if (!empty($response)) {53 return self::_parse($response['body']);54 } else {55 return false;56 }47 $response = wp_remote_get($URI); 48 49 if (!empty($response)) { 50 return self::_parse($response['body']); 51 } else { 52 return false; 53 } 57 54 } 58 55 … … 84 81 85 82 foreach ($tags AS $tag) { 86 if ($tag->hasAttribute('property') && 87 strpos($tag->getAttribute('property'), 'og:') === 0) { 83 if ($tag->hasAttribute('property') && strpos($tag->getAttribute('property'), 'og:') === 0) { 88 84 $key = strtr(substr($tag->getAttribute('property'), 3), '-', '_'); 89 85 $page->_values[$key] = $tag->getAttribute('content'); 90 86 } 91 87 92 //Added this if loop to retrieve description values from sites like the New York Times who have malformed it. 93 if ($tag ->hasAttribute('value') && $tag->hasAttribute('property') && 94 strpos($tag->getAttribute('property'), 'og:') === 0) { 88 // Added this if loop to retrieve description values from sites like the New York Times who have malformed it. 89 if ($tag ->hasAttribute('value') && $tag->hasAttribute('property') && strpos($tag->getAttribute('property'), 'og:') === 0) { 95 90 $key = strtr(substr($tag->getAttribute('property'), 3), '-', '_'); 96 91 $page->_values[$key] = $tag->getAttribute('value'); 97 92 } 98 //Based on modifications at https://github.com/bashofmann/opengraph/blob/master/src/OpenGraph/OpenGraph.php 93 94 // Based on modifications at https://github.com/bashofmann/opengraph/blob/master/src/OpenGraph/OpenGraph.php 99 95 if ($tag->hasAttribute('name') && $tag->getAttribute('name') === 'description') { 100 $nonOgDescription = $tag->getAttribute('content');101 }102 103 } 104 // Based on modifications at https://github.com/bashofmann/opengraph/blob/master/src/OpenGraph/OpenGraph.php96 $nonOgDescription = $tag->getAttribute('content'); 97 } 98 } 99 100 // Based on modifications at https://github.com/bashofmann/opengraph/blob/master/src/OpenGraph/OpenGraph.php 105 101 if (!isset($page->_values['title'])) { 106 $titles = $doc->getElementsByTagName('title'); 107 if ($titles->length > 0) { 108 $page->_values['title'] = $titles->item(0)->textContent; 109 } 102 $titles = $doc->getElementsByTagName('title'); 103 if ($titles->length > 0) { 104 $page->_values['title'] = $titles->item(0)->textContent; 105 } 106 } 107 108 if (!isset($page->_values['description']) && $nonOgDescription) { 109 $page->_values['description'] = $nonOgDescription; 110 } 111 112 // Fallback to use image_src if ogp::image isn't set. 113 if (!isset($page->values['image'])) { 114 $domxpath = new DOMXPath($doc); 115 $elements = $domxpath->query("//link[@rel='image_src']"); 116 117 if ($elements->length > 0) { 118 $domattr = $elements->item(0)->attributes->getNamedItem('href'); 119 if ($domattr) { 120 $page->_values['image'] = $domattr->value; 121 $page->_values['image_src'] = $domattr->value; 110 122 } 111 if (!isset($page->_values['description']) && $nonOgDescription) { 112 $page->_values['description'] = $nonOgDescription; 113 } 114 115 //Fallback to use image_src if ogp::image isn't set. 116 if (!isset($page->values['image'])) { 117 $domxpath = new DOMXPath($doc); 118 $elements = $domxpath->query("//link[@rel='image_src']"); 119 120 if ($elements->length > 0) { 121 $domattr = $elements->item(0)->attributes->getNamedItem('href'); 122 if ($domattr) { 123 $page->_values['image'] = $domattr->value; 124 $page->_values['image_src'] = $domattr->value; 125 } 126 } 127 } 123 } 124 } 128 125 129 126 if (empty($page->_values)) { return false; } … … 212 209 $og_type = $graph->type; 213 210 211 $esc_og_title = esc_html($og_title); 212 $esc_og_description = esc_html($og_description); 213 $esc_og_url = esc_url($og_url); 214 $esc_og_image = esc_url($og_image); 215 $esc_og_type = esc_html($og_type); 216 217 $merge_esc_url = ($esc_og_url === null) ? $esc_target_url : $esc_og_url; 218 219 $match_protocol = is_ssl() ? '|^https://.*$|' : '|^https?://.*$|'; 220 $filter_esc_image = preg_match($match_protocol, $esc_og_image) ? $esc_og_image : null; 221 214 222 $records[] = array( 215 'title' => $ og_title,216 'description' => $ og_description,217 'url' => $ og_url,218 'image' => $ og_image,219 'type' => $ og_type223 'title' => $esc_og_title, 224 'description' => $esc_og_description, 225 'url' => $merge_esc_url, 226 'image' => $filter_esc_image, 227 'type' => $esc_og_type 220 228 ); 229 230 // Debug: Chrome 231 //include '../debug/ChromePhp.php'; 232 //ChromePhp::log(json_encode($records)); 221 233 222 234 echo json_encode($records); -
qroko-blocks/trunk/qroko-blocks.php
r2337723 r2338987 6 6 * Author: qrac 7 7 * Author URI: https://qrac.jp/ 8 * Version: 1.0.0 8 * Version: 1.0.1 9 * Text Domain: qroko-blocks 10 * Domain Path: /languages 9 11 * License: GPL2+ 10 12 * License URI: https://www.gnu.org/licenses/gpl-2.0.txt … … 22 24 23 25 function qroko_blocks_load_textdomain() { 24 load_plugin_textdomain( 'qroko-blocks', false, basename( __DIR__) . '/languages' );26 load_plugin_textdomain( 'qroko-blocks', false, basename( dirname( __FILE__ ) ) . '/languages' ); 25 27 } 26 28 add_action( 'init', 'qroko_blocks_load_textdomain' ); … … 59 61 // Setting Translations 60 62 if ( function_exists( 'wp_set_script_translations' ) ) { 61 wp_set_script_translations( 'qroko-blocks', 'qroko-blocks' ); 63 wp_set_script_translations( 'qroko-blocks-editors', 'qroko-blocks', 64 plugin_dir_path( __FILE__ ) . 'languages/' ); 62 65 } 63 66 -
qroko-blocks/trunk/readme.txt
r2337723 r2338987 5 5 Requires at least: 5.4 6 6 Tested up to: 5.4 7 Stable tag: 1.0. 08 Requires PHP: 7.4.17 Stable tag: 1.0.1 8 Requires PHP: 5.6 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 14 14 == Description == 15 15 16 Qroko Blocks は Gutenberg にカスタムブロックを追加するプラグインです。16 Qroko Blocks is a plugin to add custom blocks to Gutenberg. It is listed in the official WordPress plugin directory. 17 17 18 「日本語環境で Gutenberg を使った場合に執筆が快適であること」を主眼として開発。主に、WordPress を headless CMS として使うテーマ「Qroko」での利用を想定していますが、他のテーマでも使えるよう依存性のない設計を心がけています。 18 Our main goal was to make writing on Gutenberg easier. Mainly used with the theme "Qroko", which uses WordPress as a headless CMS. However, we have tried to design it so that it is not dependent on other themes as well. 19 19 20 Qroko:https://github.com/qrac/qroko 20 The motif is a kabuki kuroko, which will play an active role offstage in your website production. 21 21 22 モチーフは歌舞伎の黒子です。Web サイト制作の舞台袖で活躍してくれることでしょう。 22 * Qroko: https://github.com/qrac/qroko 23 * Qroko Blocks: https://github.com/qrac/qroko-blocks 23 24 24 25 == Detail == 25 26 26 * ブログカード27 * Blog Card 27 28 28 29 == Frequently Asked Questions == 29 30 30 = どのテーマでも使えますか?=31 = Can I use it with any theme? = 31 32 32 はい。Gutenberg を有効化しているすべてのテーマで使えます。 33 Yes, you can use it with any theme that has Gutenberg enabled. 33 34 34 35 == Screenshots == 35 36 36 1. screenshot-1.png37 2. screenshot-2.png37 1. Blog Card (Editor) 38 2. Blog Card (Front) 38 39 39 40 == Changelog == 40 41 41 = 1.0.0 = 42 * First release 43 44 == Upgrade Notice == 42 = 1.0.1 = 43 * Fix Blog Card: Works without Open Graph 44 * Translation support 45 45 46 46 = 1.0.0 =
Note: See TracChangeset
for help on using the changeset viewer.