Skip to main content

Posts

WordPress REST API doesn't work on custom wordpress path

I'm working on my first wordpress custom theme and working on a custom Gutenberg block. So far it works on my setup. But worried about when users will be installing it on different paths. I'm making a REST API call like this: function( props ) { if (! props.attributes.categories ){ wp.apiFetch( { url: '/wordpress/wp-json/wp/v2/categories' } ).then(categories => { props.setAttributes ({ categories: categories }) }); } I've installed wordpress locally with MAMP on a custom path (/wordpress) instead of the main folder. So http://localhost/wordpress/ . My question is, the API URL url: '/wordpress/wp-json/wp/v2/categories' works because I've specified the exact path, adding /wordpress/ in front of the usual path, but how can I make it dynamic so that it works for whatever path users install their wordpress site to? Doing just url: '/wp-json/wp/v2/categories'

React:Convert Class component into functional [closed]

i can get this axios info with class component , but i can't convert it into simple function ,i should say that in my code i use redux,in fact this code should call from another component,and pull some info from there no matter what kind of info i get from axios, i just need to get that info from there and put it in my code class PostList extends Component { constructor(props) { super(props); this.state = { info: [] }; } componentDidMount() { axios .get("https://api2.binance.com/api/v3/ticker/24hr") .then((response) => { this.setState({ info: response.data }); console.log(response.data); }); } render() { const { info } = this.state; return ( <div> <h2>post!</h2> {info.map((user) => ( <div key={user.symbol}> <h6>{user.priceChange}</h6> </div> ))} </div> );

How to get a dynamically generated element in Angular without querySelector?

I am currently creating my own toastr service as seen in the GIF below The issue Whenever I click the CTA button I add a toast element to an array of toasts which the component is subscribed to and utilizes to update the DOM. The toasts are generated like this: export class ToastComponent implements OnInit { constructor(private toast: ToastService, protected elementRef: ElementRef) {} toasts = this.toast.Toasts; <div class="toast-wrapper wobble-animation" *ngFor="let t of toasts.value" (click)="DestroyToast(t, $event)" What I want I want to add an eventlistener to the toast whenever 'animationend' to destroy the HTML element. I already do this by when clicking with this line of code: DestroyToast(element, event): void { event.target.classList.remove('wobble-animation'); event.target.classList.add('slide-out-animation'); event.target.addEventListener('animationend&

Pagination in TypeORM/NestJS

I have to introduce pagination in findAll() method. I really dont know how to do it. I tried but it is giving so many errors. I used findAndCount() method given by typeorm for that, But I am not sure how it will work. As of now below method returning all the record. I need to return at a time 10 records. Please suggest what modification I need to do. async findAll(queryCertificateDto: QueryCertificateDto,page=1): Promise<PaginatedResult> { let { country, sponser } = queryCertificateDto; const query = this.certificateRepository.createQueryBuilder('certificate'); if (sponser) { sponser = sponser.toUpperCase(); query.andWhere('Upper(certificate.sponser)=:sponser', { sponser }); } if (country) { country = country.toUpperCase(); query.andWhere('Upper(certificate.country)=:country', { country }); } const certificates = query.getMany(); return certificates; } this is Pagina

Create a grid with equal sizes for picture frames

I want to have these three images in a grid with equal width inside thier container with 50% width of the screen as this: .three-image-container { display: grid; grid-template-columns: auto auto auto; grid-gap: 10px; width 50%; } .img-frame-container { border: 5px solid #e8e8e8; border-image: linear-gradient(#a8acb180, #aeb1b682); box-shadow: 1px 7px 20px 9px rgb(0 0 0 / 75%); border-radius: 5px; cursor: pointer; background: #dfe4ea; user-select: none; width: 100%; height: 100px; max-width: 100%; box-sizing: border-box; object-fit: cover; transition: all 0.2s ease; } .img-frame { width: 100%; height: 100%; object-fit: cover; } <div class="three-image-container"> <div class="img-frame-container green-frame"> <img class="img-frame" src="https://images.unsplash.com/photo-1488161628813-04466f872be2?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit

Is there way to scp within a local network, from PHP, with beginner programmer skills

I have a local network behind a router, so addresses are like 192.168.1.xxx. I need php to get files from other systems in that network. Looked into php ssh but (1) it's way beyond my skill level and (2) ssh_connect is not available on my installation. I can do it with command line scp, but not php. Is there something easier for a newbie to understand, using php, to get/put files between local systems? source https://stackoverflow.com/questions/70137726/is-there-way-to-scp-within-a-local-network-from-php-with-beginner-programmer-s

Why I can't display html from Summernote?

Hello everyone can you help me. I try to display HTML on .blade from Summernote text editor but it shows like this pic. source https://stackoverflow.com/questions/70137394/why-i-cant-display-html-from-summernote