Server IP : 103.119.228.120 / Your IP : 3.17.179.132 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/softaculous/sitepad/editor/site-data/plugins/pagelayer-pro/js/react/src/components/ |
Upload File : |
import { __ } from '@wordpress/i18n'; import { LabelControl } from './label'; import { useState, useRef, useEffect } from '@wordpress/element'; import { __experimentalLinkControl as LinkControl, __experimentalLinkControlSearchInput as LinkControlSearchInput } from '@wordpress/blockEditor'; const { internal_linking_nonce } = pagelayer_config; // TODO: re-arrang the content export const CustomLinkControl = (props) =>{ // TODO further improve const { attributes, prop, value, setAttributes } = props; const { name } = prop['c']; const tmpAtts = attributes?.tmpAtts ? attributes.tmpAtts : {}; const [values, setValues] = useState({}); const [settingOpt, setSettingOpt] = useState(false); const [toggleSetting, setToggleSetting] = useState(false); const [link, setLink] = useState(''); const holderRef = useRef(null); const getLinkVal = function(val){ if(typeof val === 'object' && pagelayerLength(val) == 1 && 'link' in val){ return val['link']; } return val; } const setAttributesHandler = (setValue) => { var updatedValues = {...values}; for(var key in setValue){ if(!pagelayer_empty(setValue[key])) { updatedValues[key] = setValue[key]; continue; } delete updatedValues[key]; } var linkValue = getLinkVal(updatedValues); linkValue = pagelayer_empty(linkValue) ? '' : linkValue; setValues(updatedValues); setAttributes({[name]: linkValue}); } useEffect(() => { // Show link options? if('selector' in prop) { setSettingOpt(true); } var preVal = attributes[name]; // Previously saved values if (typeof preVal != 'object') { preVal = { 'link': preVal } } const linkValue = (name in tmpAtts) ? tmpAtts[name] : preVal?.link; if(!pagelayer_empty(linkValue)){ setLink(linkValue); } setAttributesHandler(preVal); }, [prop]); useEffect(() => { var listWrap = jQuery(holderRef.current).find('.pagelayer-elp-link-list'); listWrap.on('click', function(e){ e.stopPropagation(); var lEle = jQuery(e.target).closest('.pagelayer-elp-link-item'); // IF item not found if(lEle.length < 1){ return; } var perma = lEle.attr('data-permalink'); var ID = lEle.attr('data-id'); // Save and Render jQuery(holderRef.current).find('.pagelayer-elp-link').val(perma); setAttributesHandler({ link: ID, }); // save tmp value const tmp = { ...tmpAtts, [name]: perma }; setAttributes({ tmpAtts: tmp }); setLink(perma); listWrap.hide(); // Show ID // addID(ID); }); jQuery(document).on('click', function(e){ listWrap.hide(); }); }, []); const linkChangeHandler = (event) => { var linkVal = event.target.value; setLink(linkVal); setAttributesHandler({ link: linkVal }) // save tmp value const tmp = { ...tmpAtts, [name]: linkVal }; setAttributes({ tmpAtts: tmp }); // Remove ID Holder //addID(); } const handleCheckboxChange = (event) => { const { checked } = event.target; const checkboxName = event.target.name; var ischecked = checked ? true : false; setAttributesHandler({[checkboxName]: ischecked}); }; var time = {}; // Set a Link const linkInputeHandler = (e) => { e.stopPropagation(); const val = e.target.value; var listWrap = jQuery(holderRef.current).find('.pagelayer-elp-link-list'); if(!listWrap.is(':visible')){ listWrap.show(); } clearTimeout(time); time = setTimeout(function(){ jQuery.ajax({ url: pagelayer_ajax_url, type: 'post', data:{ 'action' : 'wp-link-ajax', '_ajax_linking_nonce' : internal_linking_nonce, 'search' : val, }, success: function(response) { var data = jQuery.parseJSON(response); var html = ''; //console.log('Link Data');console.log(response); if(pagelayer_empty(data)){ html = __('Custom Url'); // Remove ID Holder // addID(); }else if(typeof data === 'object'){ for(var key in data){ var vals = data[key]; html += '<div class="pagelayer-elp-link-item" data-id="'+vals['ID']+'" data-permalink="'+vals['permalink']+'">'+ '<div class="pagelayer-elp-link-title">'+ '<span class="pagelayer-elp-link-item-title" title="'+vals['title']+'">'+vals['title']+'</span>'+ '<span class="pagelayer-elp-link-item-perma" title="'+vals['permalink']+'">'+vals['permalink']+'</span>'+ '</div>'+ '<div class="pagelayer-elp-link-info">'+ '<span title="'+vals['info']+'">'+vals['info']+'</span>'+ '</div>'+ '</div>'; } } listWrap.html(html); }, fail: function(data) { listWrap.html('Some error occured in getting the link data'); } }); }, 200); }; return ( <div className="components-base-control pagelayer-base-control" ref={holderRef}> <LabelControl {...props} /> <div className={`pagelayer-elp-link-div pagelayer-elp-input-icon ${settingOpt ? '' : 'pagelayer-elp-link-no-addons'}`}> <input className="pagelayer-elp-link" type="text" value={link} onChange={linkChangeHandler} onInput={linkInputeHandler} /> <i className="pli pli-service pagelayer-elp-link-icon" title={'link_options'} onClick={ () => setToggleSetting(!toggleSetting)}></i> <div className="pagelayer-elp-link-list"> {/* Render the list items here */} </div> {settingOpt && toggleSetting && ( <div className="pagelayer-elp-link-addons"> <div className="pagelayer-elp-link-cb-div"> <div className="pagelayer-elp-link-label-div"> <label className="pagelayer-elp-link-label">{ __('Open link in new window (tab)') }</label> </div> <div> <input type="checkbox" name="target" className="pagelayer-elp-checkbox" checked={!pagelayer_empty(values['target'])} onChange={handleCheckboxChange} /> </div> </div> <div className="pagelayer-elp-link-cb-div" > <div className="pagelayer-elp-link-label-div"> <label className="pagelayer-elp-link-label">{ __('Add Nofollow') }</label> </div> <div> <input type="checkbox" name="rel" className="pagelayer-elp-checkbox" checked={!pagelayer_empty(values['rel'])} onChange={handleCheckboxChange} /> </div> </div> <div className="pagelayer-elp-link-ca" > <div className="pagelayer-elp-link-label-div"> <label className="pagelayer-elp-link-label">{ __('Custom Attributes') }</label> </div> <input type="text" className="pagelayer-elp-text" placeholder="key = value" value={values?.attrs} onChange={(event) => setAttributesHandler({'attrs': event.target.value})} /> <p className="pagelayer-elp-link-desc"> { __('Setting custom attribute for link. ')} <strong>{ __('attribute = value')}</strong> { __('In this way the attribute and its value can be added. Separate key-value pairs using')} <strong> { __('semicolon ;')}</strong>. </p> </div> </div> )} </div> </div> ); }