Skip to content

Commit

Permalink
Remove redundant code #50
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Nov 18, 2021
1 parent 6485b9f commit e5c176d
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions src/oik-blockicon/blockvariations.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@

/*
* Block variations - displays information about blocks that have variations
*
* @copyright (C) Copyright Bobbing Wide 2020
* @author Herb Miller @bobbingwide
*
*/

const { Fragment } = wp.element;
const { BlockIcon } = wp.blockEditor;
const { getBlockVariations} = wp.blocks;
const { select } = wp.data;

import { BlockListItem } from "../oik-blocklist/blocklist";

/**
Expand All @@ -21,12 +14,10 @@ import { BlockListItem } from "../oik-blocklist/blocklist";
* @returns {JSX.Element|null}
* @constructor
*/

function BlockVariations( blockname ) {
if ( blockname.variations === undefined ) {
return null;
}
//const blockVariations = getBlockVariations( blockname.name, 'block');
var blockVariations = blockname.variations;
//console.log( blockVariations );
return( <dl>
Expand Down Expand Up @@ -66,9 +57,7 @@ function getAllBlockVariations( block_types ) {
* @param block_type
* @returns {*}
*/

function getPrefixedBlockVariations( block_type ) {
// var variations = getBlockVariations( block_type.name );
var variations = block_type.variations;
var prefixed_variations = variations.map(( variation ) => cloneVariation( variation, block_type ));
return prefixed_variations;
Expand All @@ -81,7 +70,6 @@ function getPrefixedBlockVariations( block_type ) {
* @param block_type
* @returns {*}
*/

function cloneVariation( variation, block_type ) {
var variationasblock = Object.assign({}, variation );
if ( variationasblock.title === undefined) {
Expand All @@ -100,7 +88,6 @@ function cloneVariation( variation, block_type ) {

}


function title_to_permalink_part( title ) {
var blockTitle = title;
blockTitle = blockTitle.replace(/ /g, '-');
Expand All @@ -110,7 +97,6 @@ function title_to_permalink_part( title ) {
return blockTitle;
}


/**
* Returns the site's home URL.
*
Expand All @@ -134,38 +120,15 @@ function getHomeUrl() {
* @param block
* @returns {string}
*/

function getVariationLink( block ) {
var blockTitle = title_to_permalink_part( block.block_title );
//.replace(/ /g, '-');
//blockTitle = blockTitle.replace( /\//g, '' );
//blockTitle = blockTitle.replace( /--/g, '-' );
//blockTitle = blockTitle.toLowerCase();
//var blockName = block.name.replace('/', '-');
var blockLink = null;
//var prefix = null;
var prefix = getHomeUrl() + 'block/';
//var siteurl = select('core/editor').getPermalinkParts();
//console.log( block);
var variationTitle = title_to_permalink_part( block.title );
var blockName = block.block_name.replace( '/', '-' );

/*
if (siteurl !== null) {
//console.log(siteurl);
var postType = select('core/editor').getCurrentPostType();
//console.log( postType );
prefix = siteurl.prefix.replace( postType + '/', 'block/');
} else {
console.log("SiteURL's null");
}
*/
blockLink = `${prefix}${blockTitle}-${blockName}/${variationTitle}-${blockName}`;
return blockLink;
}


export { BlockVariations, getAllBlockVariations, getVariationLink, cloneVariation };

0 comments on commit e5c176d

Please sign in to comment.